Skip to content

BEGIN

BEGIN starts a transaction on the current connection.

BEGIN [TRANSACTION]
[ISOLATION LEVEL { READ COMMITTED | SNAPSHOT }]

READ COMMITTED takes a new committed view for each statement. SNAPSHOT fixes the committed view when the transaction begins. Without a clause, the engine uses its configured default.

TRANSACTION is optional noise syntax. The isolation level accepts READ COMMITTED and SNAPSHOT at execution time.

Success returns an empty command result and leaves a transaction active on the connection.

A second BEGIN on the same active transaction fails. Finish the transaction with COMMIT or ROLLBACK; closing an embedded transaction handle rolls it back.

SERIALIZABLE, REPEATABLE READ and READ UNCOMMITTED parse but are explicitly rejected by the executor. The 1.2 CLI drops an isolation clause and starts its default transaction; use embedded or TCP begin_with_isolation for SNAPSHOT.

BEGIN needs an authenticated session with CONNECT. Statements inside the transaction are authorized independently when they execute.

CREATE TABLE ref_begin (id INTEGER PRIMARY KEY);
BEGIN;
INSERT INTO ref_begin VALUES (1);
ROLLBACK;
SELECT id FROM ref_begin;

See Transactions and Concurrency, COMMIT and ROLLBACK.