START TRANSACTION

START TRANSACTION – start a transaction

START TRANSACTION transaction-mode [ , ... ] ;

where transaction-mode is one of:

ISOLATION { SERIALIZABLE | REPEATABLE READ }
READ WRITE | READ ONLY
DEFERRABLE | NOT DEFERRABLE

This command starts a new transaction block.

Any EdgeDB command outside of an explicit transaction block starts an implicit transaction block; the transaction is then automatically committed if the command was executed successfully, or automatically rollbacked if there was an error. This behaviour is often called “autocommit”.

The transaction-mode can be one of the following:

ISOLATION SERIALIZABLE

All statements of the current transaction can only see data changes committed before the first query or data-modification statement was executed in this transaction. If a pattern of reads and writes among concurrent serializable transactions would create a situation which could not have occurred for any serial (one-at-a-time) execution of those transactions, one of them will be rolled back with a serialization_failure error.

ISOLATION REPEATABLE READ

All statements of the current transaction can only see data committed before the first query or data-modification statement was executed in this transaction.

This is the default.

READ WRITE

Sets the transaction access mode to read/write.

This is the default.

READ ONLY

Sets the transaction access mode to read-only. Any data modifications with INSERT, UPDATE, or DELETE are disallowed. Schema mutations via DDL are also disallowed.

DEFERRABLE

The transaction can be set to deferrable mode only when it is SERIALIZABLE and READ ONLY. When all three of these properties are selected for a transaction, the transaction may block when first acquiring its snapshot, after which it is able to run without the normal overhead of a SERIALIZABLE transaction and without any risk of contributing to or being canceled by a serialization failure. This mode is well suited for long-running reports or backups.

Start a new transaction and rollback it:

Copy
START TRANSACTION;
SELECT 'Hello World!';
ROLLBACK;

Start a serializable deferrable transaction:

Copy
START TRANSACTION ISOLATION SERIALIZABLE, READ ONLY, DEFERRABLE;
Light
Dark
System