3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "BEGIN" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 BEGIN \- start a transaction block
35 BEGIN [ WORK | TRANSACTION ] [ \fItransaction_mode\fR [, \&.\&.\&.] ]
37 where \fItransaction_mode\fR is one of:
39 ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }
40 READ WRITE | READ ONLY
46 initiates a transaction block, that is, all statements after a
48 command will be executed in a single transaction until an explicit
52 is given\&. By default (without
55 executes transactions in
57 mode, that is, each statement is executed in its own transaction and a commit is implicitly performed at the end of the statement (if execution was successful, otherwise a rollback is done)\&.
59 Statements are executed more quickly in a transaction block, because transaction start/commit requires significant CPU and disk activity\&. Execution of multiple statements inside a transaction is also useful to ensure consistency when making several related changes: other sessions will be unable to see the intermediate states wherein not all the related updates have been done\&.
61 If the isolation level, read/write mode, or deferrable mode is specified, the new transaction has those characteristics, as if
70 Optional key words\&. They have no effect\&.
74 SET TRANSACTION (\fBSET_TRANSACTION\fR(7))
75 for information on the meaning of the other parameters to this statement\&.
78 \fBSTART TRANSACTION\fR
79 has the same functionality as
86 to terminate a transaction block\&.
90 when already inside a transaction block will provoke a warning message\&. The state of the transaction is not affected\&. To nest transactions within a transaction block, use savepoints (see
91 \fBSAVEPOINT\fR(7))\&.
93 For reasons of backwards compatibility, the commas between successive
94 \fItransaction_modes\fR
98 To begin a transaction block:
114 language extension\&. It is equivalent to the SQL\-standard command
115 \fBSTART TRANSACTION\fR, whose reference page contains additional compatibility information\&.
119 \fItransaction_mode\fR
122 language extension\&.
126 key word is used for a different purpose in embedded SQL\&. You are advised to be careful about the transaction semantics when porting database applications\&.
128 \fBCOMMIT\fR(7), \fBROLLBACK\fR(7), START TRANSACTION (\fBSTART_TRANSACTION\fR(7)), \fBSAVEPOINT\fR(7)