1 .\\" auto-generated by docbook2man-spec $Revision: 1.1 $
2 .TH "SET TRANSACTION" "7" "2003-11-02" "SQL - Language Statements" "SQL Commands"
4 SET TRANSACTION \- set the characteristics of the current transaction
10 [ ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE } ] [ READ WRITE | READ ONLY ]
11 SET SESSION CHARACTERISTICS AS TRANSACTION
12 [ ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE } ] [ READ WRITE | READ ONLY ]
17 The \fBSET TRANSACTION\fR command sets the transaction
18 characteristics of the current transaction. It has no effect on any
19 subsequent transactions. \fBSET SESSION
20 CHARACTERISTICS\fR sets the default transaction
21 characteristics for each transaction of a session. \fBSET
22 TRANSACTION\fR can override it for an individual
25 The available transaction characteristics are the transaction
26 isolation level and the transaction access mode (read/write or
29 The isolation level of a transaction determines what data the
30 transaction can see when other transactions are running concurrently.
33 A statement can only see rows committed before it began. This
37 The current transaction can only see rows committed before
38 first query or data-modification statement was executed in this transaction.
42 Intuitively, serializable means that two concurrent
43 transactions will leave the database in the same state as if
44 the two has been executed strictly after one another in either
49 The transaction isolation level cannot be set after the first query
50 or data-modification statement (\fBSELECT\fR,
51 \fBINSERT\fR, \fBDELETE\fR,
52 \fBUPDATE\fR, \fBFETCH\fR,
53 \fBCOPY\fR) of a transaction has been executed. See
54 the chapter called ``Concurrency Control'' in the documentation for more information about transaction
55 isolation and concurrency control.
57 The transaction access mode determines whether the transaction is
58 read/write or read-only. Read/write is the default. When a
59 transaction is read-only, the following SQL commands are
60 disallowed: INSERT, UPDATE,
61 DELETE, and COPY TO if the
62 table they would write to is not a temporary table; all
64 DROP commands; COMMENT,
66 TRUNCATE; and EXPLAIN ANALYZE
67 and EXECUTE if the command they would execute is
68 among those listed. This is a high-level notion of read-only that
69 does not prevent writes to disk.
72 The session default transaction isolation level can also be set
76 SET default_transaction_isolation = '\fIvalue\fR'
79 and in the configuration file. Consult the section called ``Run-time Configuration'' in the documentation for more
83 Both commands are defined in the SQL standard.
84 SERIALIZABLE is the default transaction
85 isolation level in the standard; in PostgreSQL the default is
86 ordinarily READ COMMITTED, but you can change it as
87 described above. PostgreSQL does not
88 provide the isolation levels READ UNCOMMITTED
89 and REPEATABLE READ. Because of multiversion
90 concurrency control, the SERIALIZABLE level is
91 not truly serializable. See the chapter called ``Concurrency Control'' in the documentation for details.
93 In the SQL standard, there is one other transaction characteristic
94 that can be set with these commands: the size of the diagnostics
95 area. This concept is only for use in embedded SQL.