SHOW TRANSACTIONS

List all running transactions. The command can be used to show transactions for the current user or all users in the account.

See also:

SHOW LOCKS

Syntax

SHOW TRANSACTIONS [ IN ACCOUNT ]
Copy

Parameters

IN ACCOUNT

Shows all transactions across all users in the account. It can only be used by users with the ACCOUNTADMIN role (i.e. account administrators).

Output

The command output shows transaction metadata in the following columns:

Column

Description

id

Transaction ID (a signed 64-bit integer).

user

Current user.

session

Session ID.

name

User-defined name or system-generated name (UUID) for the transaction.

started_on

Timestamp that specifies when the transaction started executing.

state

Transaction state: running.

scope

ID of the operation that created a stored procedure in a scoped transaction. 0 for non-scoped transactions.

Usage notes

  • Columns that start with the prefix is_ return either Y (yes) or N (no).

  • The command does not require a running warehouse to execute.

  • The command returns a maximum of 10K records for the specified object type, as dictated by the access privileges for the role used to execute the command; any records above the 10K limit are not returned, even with a filter applied.

    To view results for which more than 10K records exist, query the corresponding view (if one exists) in the Snowflake Information Schema.

  • To post-process the output of this command, you can use the RESULT_SCAN function, which treats the output as a table that can be queried.

  • The command output includes the IDs for all running transactions. These IDs can be used as input for SYSTEM$ABORT_TRANSACTION to abort a specified transaction.

  • A stored procedure that contains a transaction can be called from within another transaction. These transactions are separate but “scoped.” The values in the scope column are useful for discovering whether two transactions are in the same scope. For more information, see Scoped transactions.

Example

In this example, two sessions are being run by the same user, with one transaction in progress for each session.

SHOW TRANSACTIONS;
Copy
+---------------------+---------+-----------------+--------------------------------------+-------------------------------+---------+-------+
|                  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 |
+---------------------+---------+-----------------+--------------------------------------+-------------------------------+---------+-------+