On this page Carat arrow pointing down
As of April 12, 2019, CockroachDB v1.1 is no longer supported. For more details, refer to the Release Support Policy.

The COMMIT statement commits the current transaction or, when using client-side transaction retries, clears the connection to allow new transactions to begin.

When using client-side transaction retries, statements issued after SAVEPOINT cockroach_restart are committed when RELEASE SAVEPOINT cockroach_restart is issued instead of COMMIT. However, you must still issue a COMMIT statement to clear the connection for the next transaction.

For non-retryable transactions, if statements in the transaction generated any errors, COMMIT is equivalent to ROLLBACK, which aborts the transaction and discards all updates made by its statements.



Required Privileges

No privileges are required to commit a transaction. However, privileges are required for each statement within a transaction.


In CockroachDB, END is an alias for the COMMIT statement.


Commit a Transaction

How you commit transactions depends on how your application handles transaction retries.

Client-Side Retryable Transactions

When using client-side transaction retries, statements are committed by RELEASE SAVEPOINT cockroach_restart. COMMIT itself only clears the connection for the next transaction.


> SAVEPOINT cockroach_restart;

> UPDATE products SET inventory = 0 WHERE sku = '8675309';

> INSERT INTO orders (customer, sku, status) VALUES (1001, '8675309', 'new');

> RELEASE SAVEPOINT cockroach_restart;

This example assumes you're using client-side intervention to handle transaction retries.

Automatically Retried Transactions

If you are using transactions that CockroachDB will automatically retry (i.e., all statements sent in a single batch), commit the transaction with COMMIT.

> BEGIN; UPDATE products SET inventory = 100 WHERE = '8675309'; UPDATE products SET inventory = 100 WHERE = '8675310'; COMMIT;

See Also

Yes No
On this page

Yes No