Light
Dark
System
v4latest
v5dev
v4latest
v3
v2
v1

Start transaction

start transaction – start a transaction

start transaction transaction-mode [ , ... ] ;

where transaction-mode is one of:

isolation serializable
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 behavior 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.

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

We use ChatGPT with additional context from our documentation to answer your questions. Not all answers will be accurate. Please join our Discord if you need more help.