Contents
SET TRANSACTION
A command for setting the type of the current transaction
SET TRANSACTION
is a transaction command for setting transaction characteristics.
SET TRANSACTION
was added in PostgreSQL 6.5.
Usage
SET TRANSACTION
can perform one of three different tasks:
- setting the current transaction mode
- setting the session transaction mode
- setting the session snapshot
Change history
- PostgreSQL 7.3
READ ONLY
andREAD WRITE
syntax added (commit 90edb265)
- PostgreSQL 6.5
- added (initial commit 3498d878)
Examples
Basic execution example for SET TRANSACTION
:
postgres=# BEGIN; BEGIN postgres=*# SET TRANSACTION READ ONLY; SET postgres=*# INSERT INTO foo VALUES(1); ERROR: cannot execute INSERT in a read-only transaction
SET TRANSACTION
is only effective if a transaction is in progress:
postgres=# SET TRANSACTION READ ONLY; WARNING: SET TRANSACTION can only be used in transaction blocks SET
References
- PostgreSQL documentation: SET TRANSACTION
Categories
See also
default_transaction_isolation, default_transaction_deferrable, default_transaction_read_only, pg_export_snapshot()