# Drop table

一或多個 QlikView 內部資料表可在指令碼執行期間的任何時間，透過 drop table 陳述式從資料模型 (進而從記憶體) 捨棄。 可選擇使用 drop mapping table 變體，在指令碼執行結束前捨棄對應表格──即使用 Mapping 前置詞建立的表格。

drop [mapping] table tablename [, tablename2 ...]

drop [mapping] tables [ tablename [, tablename2 ...]

資訊備註drop table 與 drop tables 兩者均可。

下列項目將因此捨去：

* 實際表格。
* 不屬於剩餘表格的所有欄位。
* 完全來自於捨棄表格的剩餘欄位中的欄位值。

範例與結果

| 範例 | 結果 |
| --- | --- |
| ```<br>drop table Orders, Salesmen, T456a;<br>``` | 這一行將導致從記憶體捨棄三個表格。 |
| ```<br>Tab1:<br>Load * Inline [<br>Customer, Items, UnitPrice<br>Bob, 5, 1.50<br>];<br> <br>Tab2:<br>LOAD Customer, Sum( Items * UnitPrice ) as Sales<br>resident Tab1<br>group by Customer;<br> <br>drop table Tab1;<br>``` | 建立表格 Tab2 後，將捨棄表格 Tab1。 |
| ```<br>// Load mapping table of country codes:<br>map1:<br>mapping LOAD *<br>Inline [<br>CCode, Country<br>Sw, Sweden<br>Dk, Denmark<br>No, Norway<br>] ;<br>// Load list of salesmen, mapping country code to country<br>// If the country code is not in the mapping table, put Rest of the world<br>Salespersons:<br>LOAD *,<br>ApplyMap('map1', CCode,'Rest of the world') As Country<br>Inline [<br>CCode, Salesperson<br>Sw, John<br>Sw, Mary<br>Sw, Per<br>Dk, Preben<br>Dk, Olle<br>No, Ole<br>Sf, Risttu] ;<br>// We don't need the CCode anymore<br>Drop Field 'CCode';<br>									<br>Drop Mapping Table map1;<br><br>Metrics:<br><br>Load * Inline [<br>Transaction ID, Sales Amount, Sales Cost, City, Customer ID<br>1000012, 4509.33, 1234.22, Oslo, 250v9849<br>1000013, 1043.21, 180.23, Gothenburg, 195d5930<br>1000014, 6038.35, 1400.10, Copenhagen, 195d5930<br><br>];<br>``` | 此範例說明如何使用 Drop mapping table 變體。會建立一個對應表格 map1，然後在後續的 LOAD 陳述式中使用 ApplyMap 函數。對應表格使用後，會從記憶體中捨棄，以最佳化 RAM 使用量，供指令碼執行後續表格中要載入的資料使用。<br><br>在此情況下，對應表格中只有少數幾列，RAM 最佳化效果會很小。然而，對於大型對應表格或在迴圈中建立對應表格時，效能可以顯著提升。 |

[Rename table](https://help.qlik.com/zh-TW/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/rename-table.htm)

[Drop field](https://help.qlik.com/zh-TW/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/drop-field.htm)

[Drop](https://help.qlik.com/zh-TW/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Drop.htm)

[Table/Tables](https://help.qlik.com/zh-TW/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Table.htm)

[Mapping](https://help.qlik.com/zh-TW/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptPrefixes/Mapping.htm)