2000-11-24SET TRANSACTIONSQL - Language StatementsSET TRANSACTIONset the characteristics of the current transaction
SET TRANSACTION
[ ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE } ] [ READ WRITE | READ ONLY ]
SET SESSION CHARACTERISTICS AS TRANSACTION
[ ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE } ] [ READ WRITE | READ ONLY ]
Description
The SET TRANSACTION command sets the transaction
characteristics of the current SQL-transaction. It has no effect on
any subsequent transactions. SET SESSION
CHARACTERISTICS sets the default transaction
characteristics for each transaction of a session. SET
TRANSACTION can override it for an individual
transaction.
The available transaction characteristics are the transaction
isolation level and the transaction access mode (read/write or
read-only).
The isolation level of a transaction determines what data the
transaction can see when other transactions are running concurrently.
READ COMMITTED
A statement can only see rows committed before it began. This
is the default.
SERIALIZABLE
The current transaction can only see rows committed before
first query or data-modification statement was executed in this transaction.
Intuitively, serializable means that two concurrent
transactions will leave the database in the same state as if
the two has been executed strictly after one another in either
order.
The transaction isolation level cannot be set after the first query
or data-modification statement (SELECT,
INSERT, DELETE,
UPDATE, FETCH,
COPY) of a transaction has been executed.
The transaction access mode determines whether the transaction is
read/write or read-only. Read/write is the default. When a
transaction is read-only, the following SQL commands are
disallowed: INSERT, UPDATE,
DELETE, and COPY TO if the
table they would write to is not a temporary table; all
CREATE, ALTER, and
DROP commands; COMMENT,
GRANT, REVOKE,
TRUNCATE; and EXPLAIN ANALYZE
and EXECUTE if the command they would execute is
among those listed. This is a high-level notion of read-only that
does not prevent writes to disk.
Notes
The session default transaction isolation level can also be set
with the command
SET default_transaction_isolation = 'value'
and in the configuration file. Consult for more
information.
CompatibilitySQL92, SQL99
is the default transaction isolation level in
SQL. PostgreSQL does
not provide the isolation levels
and . Because of multiversion
concurrency control, the level is not
truly serializable. See for details.
In SQL there is one other transaction
characteristic that can be set with these commands: the size of
the diagnostics area. This concept is not supported in
PostgreSQL.