BEGIN initiates a , which either successfully executes all of the statements it contains or none at all.
When running under the default isolation level, your application should that can occur under .
Synopsis
Required privileges
No are required to initiate a transaction. However, privileges are required for each statement within a transaction.Aliases
In CockroachDB, the following are aliases for theBEGIN statement:
BEGIN TRANSACTIONSTART TRANSACTION
Parameters
CockroachDB now only supports
SERIALIZABLE isolation, so transactions can no longer be meaningfully set to any other ISOLATION LEVEL. In previous versions of CockroachDB, you could set transactions to SNAPSHOT isolation, but that feature has been removed.
Examples
Begin a transaction
Use default settings
Without modifying theBEGIN statement, the transaction uses SERIALIZABLE isolation and NORMAL priority.
Change priority
You can set a transaction’s priority toLOW or HIGH.
This example assumes you’re using .
Use the AS OF SYSTEM TIME option
You can execute the transaction using the database contents “as of” a specified time in the past.
Begin a transaction with automatic retries
CockroachDB will all transactions that contain bothBEGIN and COMMIT in the same batch. Batching is controlled by your driver or client’s behavior, but means that CockroachDB receives all of the statements as a single unit, instead of a number of requests.
From the perspective of CockroachDB, a transaction sent as a batch looks like this:

