# 脚本常规语句

常规语句通常用于以某种方式或其他方式操作数据。这些语句可能被脚本中的行编号覆盖且必须总是以分号“;”终止。

所有脚本关键字可以大小写字符的任意组合输入。用于脚本中的字段和变量名要区分大小写。

使用每个函数的下拉列表可查看每个函数的简短描述和语法。单击语法描述中的函数名称可了解更多信息。

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 别名

alias 语句用于设置别名。根据此别名，每当后面的脚本中出现相应字段时其都会重命名。

[**Alias**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Alias.htm) fieldname as aliasname {,fieldname as aliasname}

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### AutoNumber

此语句为脚本执行过程中遇到的字段中的每个不同计算值创建一个唯一的整数值。

[**Autonumber**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Autonumber.htm) \*fieldlist

[Using namespace] ]

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 二进制

binary 语句用于加载另一个 QlikView 文档的数据，包括区域权限数据。

[**Binary**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Binary.htm) [[path] filename]

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 评论字段

提供一种从数据库和电子表格显示表格注释（元数据）的方式。可以忽略在文档中不显示的字段名。如果有字段名多次出现，将使用最后出现的值。

[**comment**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/comment.htm) \*fieldlist using mapname

[**comment**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/comment.htm) fieldname with comment

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 评论表

提供一种从数据库或电子表格显示表格注释（元数据）的方式。

[**comment-table**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/comment-table.htm) tablelist using mapname

[**comment-table**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/comment-table.htm) tablename with comment

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 连接

CONNECT 语句用于定义 QlikView 通过 OLE DB/ODBC 接口访问通用数据库。对于 ODBC，首先需要用 ODBC 管理员指定数据源。

ODBC [CONNECT](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/CONNECT.htm) TO connect-string

OLEDB CONNECT TO connect-string

CUSTOM CONNECT TO connect-string

LIB CONNECT TO connection

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 目录

Directory 语句用于定义在后续 LOAD 语句中查找数据文件的目录，直到出现新的 Directory 语句。

[**Directory**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Directory.htm) [path]

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 断开连接

Disconnect 语句用于终止当前 ODBC/OLE DB/自定义连接。此语句为可选。

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

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 放置字段

在执行脚本期间，可以使用 drop field 语句随时从数据模型和内存中删除一个或多个 QlikView 字段。表的“distinct”属性在 drop field 语句之后被删除。

信息注释drop field 和 drop fields 都是允许的格式，效果完全一样。 如果未指定任何表格，字段将从全部表格中删除。

[**drop-field**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/drop-field.htm) fieldname [ , fieldname2 ...] [from tablename1 [ , tablename2 ...]]

drop fields fieldname [ , fieldname2 ...] [from tablename1 [ , tablename2 ...]]

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 删除表

在脚本执行期间的任何时间，都可以通过 drop table 语句从数据模型（并进而从内存）中删除一个或多个 QlikView 内部表。 （可选）使用 drop mapping table 变体在脚本执行结束前删除映射表——即使用 Mapping 前缀创建的映射表。

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

[Drop \[mapping\] table](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/drop-table.htm) tablename [, tablename2 ...]

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

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 删除变量

使用 Drop variable 语句在脚本执行期间删除一个脚本变量。

信息注释

drop variable 和 drop variables 都是允许的格式，效果完全一样。

[Drop variable](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Drop-Variable.htm) variablename [ , variablename2 ...]

Drop variables variablename [ , variablename2 ...]

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 执行

Execute 语句用于在 QlikView 加载数据的同时运行其他程序。例如，需要执行转换。

[**Execute**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Execute.htm) commandline

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 强制

force 语句用于强制 QlikView 将后面的 LOAD 和 SELECT 语句的字段值写入方式解释为仅限大写字母，仅限小写字母，总是首字母大写或它们的原初显示形式（大小写混合）。此语句可以根据不同的惯例关联表格的字段值。

[**Force**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Force.htm) ( capitalization | case upper | case lower | case mixed )

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### LOAD

LOAD 语句可以加载以下来源的字段：文件、脚本中定义的数据、预先载入的输入表格、网页、后续 SELECT 语句产生的结果或自动生成的数据。

[**Load**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm) [ distinct ] \*fieldlist

[( from file [ format-spec ] |

from\_field fieldassource [format-spec]

inline data [ format-spec ] |

resident table-label |

autogenerate size )]

[ where criterion | while criterion ]

[ group\_by groupbyfieldlist ]

[order\_by orderbyfieldlist ]

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 让

let 语句是 set 语句的补充，用于定义脚本变量。相对于 set 语句，let 语句在其被分配到变量之前可以计算等号“=”右边的表达式。

[**Let**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Let.htm) variablename=expression

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 松开工作台

在使用 Loosen Table 语句执行脚本期间，一个或多个 QlikView 内部数据表格可以明确声明松散耦合。执行脚本之前，在脚本中使用一个或多个 Loosen Table 语句将使 QlikView 忽略任何松散耦合表设置。

[**loosen-table**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/loosen-table.htm) tablename [ , tablename2 ...]

Loosen Tables tablename [ , tablename2 ...]

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 使用……映射

map ... using 语句用于将某些字段值或表达式映射为特定映射表的值。映射表可通过 Mapping 语句创建。

[**Map**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Map.htm) \*fieldlist Using mapname

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### NullAsNull

NullAsNull 语句用于关闭 NULL 语句之前设置的从 NullAsValue 值到字符串值的转换。

[**NullAsNull**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/NullAsNull.htm) \*fieldlist

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### NullAsValue

NullAsValue 语句用于指定应将 NULL 值转换为值的字段。

[**NullAsValue**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/NullAsValue.htm) \*fieldlist

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 资格审查

Qualify 语句用于打开字段名限制条件，即字段名将表格名作为前缀。

[**Qualify**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Qualify.htm) \*fieldlist

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 备注

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)rem 语句用于插入备注或注释到脚本，或暂时关闭脚本语句而无需移除脚本。

[**Rem**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Rem.htm) string

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 重命名字段

此脚本函数用于在加载一个或多个现有 QlikView 字段后对其进行重命名。

[**rename-field**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/rename-field.htm) (using mapname | oldname to newname{ , oldname to newname })

Rename Fields (using mapname | oldname to newname{ , oldname to newname })

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 重命名表格

此脚本函数用于在加载一个或多个现有 QlikView 内部表格后对其进行重命名。

[**rename-table**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/rename-table.htm) (using mapname | oldname to newname{ , oldname to newname })

Rename Tables (using mapname | oldname to newname{ , oldname to newname })

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 节

使用 section 语句，可以定义随后的 LOAD 和 SELECT 语句应视为数据还是访问权限定义。

[**Section**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Section.htm) (access | application)

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 选择

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)可通过标准 SQL SELECT 语句从 ODBC 数据源或 OLE DB 提供商选择字段。然而，是否接受 SELECT 语句取决于所使用的 ODBC 驱动程序或 OLE DB 提供程序。

[**Select**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Select.htm) [all | distinct | distinctrow | top n [percent] ] \*fieldlist

From tablelist

[Where criterion ]

[Group by fieldlist [having criterion ] ]

[Order by fieldlist [asc | desc] ]

[ (Inner | Left | Right | Full)Join tablename on fieldref = fieldref ]

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 设置

set 语句用于定义脚本变量。这些变量可用来替代字符串，路径和驱动程序等。

[**Set**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Set.htm) variablename=string

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 睡眠

sleep 语句用于在指定的时间暂停脚本执行。

[**Sleep**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Sleep.htm) n

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### SQL

SQL 语句可通过 ODBC 或 OLE DB 连接发送任意 SQL 命令。

[**SQL**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/SQL.htm) sql\_command

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### SQLColumns

sqlcolumns 语句用于返回描述 ODBC 或 OLE DB 数据源的列以建立 connect 的字段集。

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

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### SQLTables

sqltables 语句用于返回描述 ODBC 或 OLE DB 数据源的表格以建立 connect 的字段集。

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

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### SQLTypes

sqltypes 语句用于返回描述 ODBC 或 OLE DB 数据源的类型以建立 connect 的字段集。

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

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 星标

该字符串用于呈现数据库中字段的全部值设置，可以通过 star 语句设置。星号可以影响随后的LOAD 和 SELECT 语句。

[**Star**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Star.htm) is [ string ]

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 商店

此脚本函数用于创建 QVD 或 CSV 文件。

[**Store**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Store.htm) [ \*fieldlist from] table into filename [ format-spec ];

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 标签

此脚本函数用于提供将标签分配给一个或多个字段的方法。如果试图标记文档中不存在的字段名称，则将忽略该标记。如果出现字段名和标记名冲突的情况，将使用最后出现的值。

[**Tag**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Tag.htm) fields fieldlist using mapname

Tag field fieldname with tagname

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 跟踪

trace 语句用于将字符串写入脚本执行进度窗口和脚本日志文件中。这对调试过程很有用。使用在 trace 语句之前计算的 $ 变量扩展可以自定义消息。

[**Trace**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Trace.htm) string

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 取消映射

Unmap 语句可禁用由之前的 Map … Using 语句为后来加载的字段指定的字段值映射。

[**Unmap**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Unmap.htm) \*fieldlist

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 判定为不合格

Unqualify 语句用于断开前面由 Qualify 语句打开的字段名限制条件。

[**Unqualify**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Unqualify.htm) \*fieldlist

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/script-regular-statements.htm)

#### 取消标记

用于提供从一个或多个字段移除标记的方法。如果试图取消标记文档中不存在的字段名称，则将忽略该取消标记。如果出现字段名和标记名冲突的情况，将使用最后出现的值。

[**Untag**](https://help.qlik.com/zh-CN/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Untag.htm) fields fieldlist using mapname

Untag field fieldname with tagname