COMMIT | Snowflake Documentation (original) (raw)

ReferenceSQL command referenceTransactionsCOMMIT

Commits an open transaction in the current session.

See also:

BEGIN , ROLLBACK , SHOW TRANSACTIONS , DESCRIBE TRANSACTION

Syntax

Parameters

WORK

Optional keyword that provides compatibility with other database systems.

Usage notes

Examples

Begin a transaction, insert some values into a table, then complete the transaction by committing it:

SELECT COUNT(*) FROM A1;

+----------+ | COUNT(*) | |----------+ | 0 | +----------+

BEGIN NAME T3;

SELECT CURRENT_TRANSACTION();

+-----------------------+ | CURRENT_TRANSACTION() | |-----------------------+ | 1432071497832 | +-----------------------+

INSERT INTO A1 VALUES (1), (2);

+-------------------------+ | number of rows inserted | |-------------------------+ | 2 | +-------------------------+

COMMIT;

SELECT CURRENT_TRANSACTION();

+-----------------------+ | CURRENT_TRANSACTION() | |-----------------------+ | [NULL] | +-----------------------+

SELECT LAST_TRANSACTION();

+--------------------+ | LAST_TRANSACTION() | |--------------------+ | 1432071497832 | +--------------------+

SELECT COUNT(*) FROM A1;

+----------+ | COUNT(*) | |----------+ | 2 | +----------+