This article will cover the syntax of the ‘drop table’ regular script statement.
The drop table statement allows you to delete a previously loaded table from the data model. Note that it does not delete the original data source table.
Statement syntax
Drop tables | table tablename { , tablename2 ...}
Tables | Table | You can specify to drop a single or multiple tables. Note that even if you use the single ‘table’ syntax you can still specify multiple table names to be dropped. It therefore makes no difference which syntax you use. |
Tablename | A comma separated list of tables to be dropped. |
Example
In this example, a list of items contained in each order id is loaded and item costs are joined from another table. A new table is created to aggregate the item costs over each order id to get total order costs. The first table containing item details is then dropped.
ORDER_ITEMS:
LOAD
orderId,
itemId
FROM [lib://Public:DataFiles/order_items.xlsx]
(ooxml, embedded labels, table is Sheet1);
LEFT JOIN
LOAD
id as itemId,
cost,
type,
flavour
FROM [lib://Public:DataFiles/item_details.xlsx]
(ooxml, embedded labels, table is Sheet1);
ORDER_COST:
LOAD
orderId,
sum(cost) as totalCost
RESIDENT ORDER_ITEMS
GROUP BY
orderId;
Drop table ORDER_ITEMS;
Result
The result is a table containing fields: “orderId” and “totalCost” only.