BEGIN
Starts a transaction block.
BEGIN is a synonym for START TRANSACTION.
Syntax
BEGIN [ WORK | TRANSACTION ] [ isolation‑level ] [ READ [ONLY] | WRITE ]
Parameters
WORK | TRANSACTION |
Optional keywords for readability only. |
isolation‑level |
Specifies the transaction's isolation level, which determines what data the transaction can access when other transactions are running concurrently, one of the following:
For details, see Transactions. |
READ [ONLY] | WRITE |
Specifies the transaction mode, one of the following:
Setting the transaction session mode to read-only disallows the following SQL statements, but does not prevent all disk write operations:
|
Privileges
None
Examples
Create a transaction with the isolation level set to READ COMMITTED and the transaction mode to READ WRITE:
=> BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED READ WRITE; BEGIN => CREATE TABLE sample_table (a INT); CREATE TABLE => INSERT INTO sample_table (a) VALUES (1); OUTPUT -------- 1 (1 row) => END; COMMIT