info > BEGIN(7)

BEGIN(7)   PostgreSQL 14.23 Documentation   BEGIN(7)

πŸ’‘ NAME

BEGIN β€” start a transaction block

πŸš€ Quick Reference

Use CaseCommandDescription
Start a transactionBEGIN;βœ… Begins a new transaction block
Start with read-only modeBEGIN READ ONLY;πŸ”’ Prevents writes during transaction
Start with serializable isolationBEGIN ISOLATION LEVEL SERIALIZABLE;πŸ” Highest isolation level β€” prevents phantom reads
Start with deferred constraintsBEGIN DEFERRABLE;⏳ Constraint checking deferred to commit

πŸ“‹ SYNOPSIS

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

πŸ“ DESCRIPTION

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.

πŸ”§ PARAMETERS

πŸ“Œ NOTES

πŸ’» EXAMPLES

To begin a transaction block:

BEGIN;

πŸ”„ COMPATIBILITY

πŸ“š SEE ALSO

COMMIT(7), ROLLBACK(7), START TRANSACTION(7), SAVEPOINT(7)

PostgreSQL 14.23   2026   BEGIN(7)

BEGIN(7)
πŸ’‘ NAME πŸš€ Quick Reference πŸ“‹ SYNOPSIS πŸ“ DESCRIPTION πŸ”§ PARAMETERS πŸ“Œ NOTES πŸ’» EXAMPLES πŸ”„ COMPATIBILITY πŸ“š SEE ALSO

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)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format