Categories:

System functions (System Control)

SYSTEM$CANCEL_QUERY

如果指定的查询(或语句)当前处于活跃/运行状态,则取消该查询(或语句)。

See also:

SYSTEM$CANCEL_ALL_QUERIES

语法

SYSTEM$CANCEL_QUERY( <query_id> )

实参

query_id

Identifier for the query to cancel. To obtain the ID for a query executed within the last 14 days, log into the web interface and go to the History History tab page.

使用说明

  • A user can cancel their own running SQL operations using this SQL function. Canceling running operations executed by another user requires a role with one of the following privileges:

    • 执行操作用户的 OWNERSHIP。
    • 运行操作的仓库的 OPERATE 或 OWNERSHIP(如果适用)。
    • ACCOUNTADMIN 角色。
  • For a query run by a task, canceling running operations requires a role with one of the following privileges:

    • 运行操作的任务的 OPERATE 或 OWNERSHIP。
    • ACCOUNTADMIN 角色。
  • Snowflake 查询 IDs 是带有连字符的 UUID 文本字符串,连字符是特殊字符,因此必须通过使用单引号对字符串进行转义。

  • 此函数不用于取消对特定仓库或用户的查询。请改用:

示例

SELECT SYSTEM$CANCEL_QUERY('d5493e36-5e38-48c9-a47c-c476f2111ce5');

+-------------------------------------------------------------+
| SYSTEM$CANCEL_QUERY('D5493E36-5E38-48C9-A47C-C476F2111CE5') |
%-------------------------------------------------------------%
| query [d5493e36-5e38-48c9-a47c-c476f2111ce5] terminated.    |
+-------------------------------------------------------------+