# Drop table

在执行脚本期间，可以使用 drop table 语句随时从数据模型和内存中删除一个或多个 Qlik Sense 内部表格。（可选）使用 drop mapping table 变体删除映射表—那些使用 Mapping 前缀创建的—在脚本执行结束之前。

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

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

信息注释可以同时接受 drop table 和 drop tables 格式。

由于此操作，将丢失以下项目：

* 实际的表。
* 不属于其余表的所有字段。
* 其余字段中的字段值，这些值完全来自已删除的表。

[](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptRegularStatements/drop-table.htm)

#### 示例和结果：

| 示例 | 结果 |
| --- | --- |
| ```<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-CN/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptRegularStatements/rename-table.htm)

[Drop field](https://help.qlik.com/zh-CN/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptRegularStatements/drop-field.htm)

[Drop](https://help.qlik.com/zh-CN/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptRegularStatements/Drop.htm)

[Table/Tables](https://help.qlik.com/zh-CN/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptRegularStatements/Table.htm)

[映射](https://help.qlik.com/zh-CN/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefixes/Mapping.htm)