SET TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE } |
SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE } |
This command sets the transaction isolation level. The SET TRANSACTION command sets the characteristics for the current SQL-transaction. It has no effect on any subsequent transactions. This command cannot be used after the first DML statement (SELECT, INSERT, DELETE, UPDATE, FETCH, COPY) of a transaction has been executed. SET SESSION CHARACTERISTICS sets the default transaction isolation level for each transaction for a session. SET TRANSACTION can override it for an individual transaction.
The isolation level of a transaction determines what data the transaction can see when other transactions are running concurrently.
A statement can only see rows committed before it began. This is the default.
The current transaction can only see rows committed before first DML statement was executed in this transaction.
To the characteristics of the current SQL-transaction:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; CREATE TABLE PKTABLE1 ( ptest1 int, ptest2 int, ptest3 int, ptest4 text, PRIMARY KEY(ptest1, ptest2, ptest3) ); CREATE TABLE FKTABLE1 ( ftest1 int, ftest2 int, ftest3 int, ftest4 int, CONSTRAINT constrname3 FOREIGN KEY(ftest1, ftest2, ftest3) REFERENCES PKTABLE1); |
SERIALIZABLE is the default level in SQL. PostgreSQL does not provide the isolation levels READ UNCOMMITTED and REPEATABLE READ. Because of multi-version concurrency control, the serial level is not truly serializable. See the Red Hat Database Administrator and User's Guidee for details.
In SQL there are two other transaction characteristics that can be set with these commands: whether the transaction is read-only and the size of the diagnostics area. Neither of these concepts are supported in PostgreSQL.