# 指令碼一般陳述式

一般陳述式通常用於以某種方式操縱資料。這些陳述式可在指令碼中撰寫為任意行數，但是一定必須以分號 ";" 終止。

所有的指令碼關鍵字皆可以小寫和大寫字元的任意組合輸入。但用於陳述式中的欄位和變數名稱則會區分大小寫。

使用各個函數的下拉式清單，查看各函數的簡短描述及語法。按一下語法描述中的函數名稱以取得更多詳細資料。

[](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-TW/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-TW/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 文件的資料，包括 Section Access 資料。

[**Binary**](https://help.qlik.com/zh-TW/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-TW/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/comment.htm) \*fieldlist using mapname

[**comment**](https://help.qlik.com/zh-TW/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-TW/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/comment-table.htm) tablelist using mapname

[**comment-table**](https://help.qlik.com/zh-TW/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-TW/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-TW/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-TW/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)

#### 置放欄位

透過 QlikView 陳述式，可以隨時在指令碼執行期間，從資料模型和記憶體捨棄一或數個 drop field 欄位。在 drop field 陳述式後移除表格的「相異」屬性。

資訊備註drop field 和 drop fields 兩者均可，效果並無不同。 如果未指定表格，將從出現欄位的所有表格中捨棄欄位。

[**drop-field**](https://help.qlik.com/zh-TW/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)

#### 捨棄表格

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

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

[Drop \[mapping\] table](https://help.qlik.com/zh-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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 陳述式會關閉先前由 NullAsValue 陳述式設定將 NULL 值變成字串值的轉換。

[**NullAsNull**](https://help.qlik.com/zh-TW/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-TW/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-TW/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)

#### Rem

[](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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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-TW/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 陳述式前計算的 $-expansions 變數，即可自訂訊息。

[**Trace**](https://help.qlik.com/zh-TW/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-TW/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-TW/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-TW/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Untag.htm) fields fieldlist using mapname

Untag field fieldname with tagname