BEGIN(7) PostgreSQL 14.23 Documentation BEGIN(7)
BEGIN β start a transaction block
| Use Case | Command | Description |
|---|---|---|
| Start a transaction | BEGIN; | β Begins a new transaction block |
| Start with read-only mode | BEGIN READ ONLY; | π Prevents writes during transaction |
| Start with serializable isolation | BEGIN ISOLATION LEVEL SERIALIZABLE; | π Highest isolation level β prevents phantom reads |
| Start with deferred constraints | BEGIN DEFERRABLE; | β³ Constraint checking deferred to commit |
BEGIN [ WORK | TRANSACTION ] [ transaction_mode [, ...] ]
where transaction_mode is one of:
ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }
READ WRITE | READ ONLY
[ NOT ] DEFERRABLE
BEGIN initiates a transaction block, that is, all statements after a BEGIN command will be executed in a single transaction until an explicit COMMIT or ROLLBACK is given. By default (without BEGIN), PostgreSQL executes transactions in βautocommitβ 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).
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.
If the isolation level, read/write mode, or deferrable mode is specified, the new transaction has those characteristics, as if SET TRANSACTION was executed.
START TRANSACTION has the same functionality as BEGIN.COMMIT or ROLLBACK to terminate a transaction block.BEGIN 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 SAVEPOINT(7)).transaction_modes can be omitted.To begin a transaction block:
BEGIN;
BEGIN is a PostgreSQL language extension. It is equivalent to the SQL-standard command START TRANSACTION, whose reference page contains additional compatibility information.DEFERRABLE transaction_mode is a PostgreSQL language extension.BEGIN 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.COMMIT(7), ROLLBACK(7), START TRANSACTION(7), SAVEPOINT(7)
PostgreSQL 14.23 2026 BEGIN(7)
Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-31 14:27 @216.73.217.152
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format