SHOW TRANSACTIONS¶
列出所有正在运行的事务。该命令可用于显示当前用户或账户中所有用户的事务。
- 另请参阅:
语法¶
SHOW TRANSACTIONS [ IN ACCOUNT ]
参数¶
IN ACCOUNT显示账户中所有用户的所有事务。它只能由具有 ACCOUNTADMIN 角色(即账户管理员)的用户使用。
输出¶
命令输出显示以下列中的事务元数据:
列 |
描述 |
|---|---|
|
事务 ID(一个有符号的 64 位整数)。 |
|
当前用户。 |
|
会话 ID。 |
|
用于事务的用户定义的名称或系统生成的名称 (UUID)。 |
|
指定事务开始执行时间的时间戳。 |
|
事务状态: |
|
在范围内事务中创建存储过程的操作 ID。对于非范围内事务,为 |
使用说明¶
命令输出包括所有运行事务的 IDs。这些 IDs 可以用作 SYSTEM$ABORT_TRANSACTION 的输入,以中止指定的事务。
包含一个事务的存储过程可以从另一个事务中调用。这些事务是独立的,但具有“范围”。
scope列中的值对于发现两个事务是否在同一范围内非常有用。有关更多信息,请参阅 范围内事务。
该命令不需要正在运行的仓库即可执行。
该命令仅返回当前用户的当前角色已获授至少一项访问权限的对象。
MANAGE GRANTS 访问权限隐式允许其持有者查看账户中的每个对象。默认情况下,只有账户管理员(具有 ACCOUNTADMIN 角色的用户)和安全管理员(具有 SECURITYADMIN 角色的用户)才具有 MANAGE GRANTS 权限。
To post-process the output of this command, you can use the pipe operator (
->>) or the RESULT_SCAN function. Both constructs treat the output as a result set that you can query.For example, you can use the pipe operator or RESULT_SCAN function to select specific columns from the SHOW command output or filter the rows.
When you refer to the output columns, use double-quoted identifiers for the column names. For example, to select the output column
type, specifySELECT "type".You must use double-quoted identifiers because the output column names for SHOW commands are in lowercase. The double quotes ensure that the column names in the SELECT list or WHERE clause match the column names in the SHOW command output that was scanned.
该命令 最多 返回指定对象类型的 1 万条记录,由用于执行命令的角色的访问权限决定。即使应用了筛选器,也不会返回任何超出 1 万条限制后的记录。
要查看存在超过 1 万条记录的结果,请在 Snowflake Information Schema 中查询相应的视图(如果存在)。
示例¶
在此示例中,同一个用户正在运行两个会话,每个会话都有一个正在进行的事务。
SHOW TRANSACTIONS;
+---------------------+---------+-----------------+--------------------------------------+-------------------------------+---------+-------+
| id | user | session | name | started_on | state | scope |
|---------------------+---------+-----------------+--------------------------------------+-------------------------------+---------+-------|
| 1721165674582000000 | CALIBAN | 186457423713330 | 551f494d-90ed-438d-b32b-1161396c3a22 | 2024-07-16 14:34:34.582 -0700 | running | 0 |
| 1721165584820000000 | CALIBAN | 186457423749354 | a092aa44-9a0a-4955-9659-123b35c0efeb | 2024-07-16 14:33:04.820 -0700 | running | 0 |
+---------------------+---------+-----------------+--------------------------------------+-------------------------------+---------+-------+