BEGIN marks the start of a transaction block. All subsequent DML statements run under the same transactional context until a COMMIT or ROLLBACK ends the block. Inside the block, changes stay invisible to other sessions, allowing atomic, consistent updates. BEGIN is synonymous with BEGIN TRANSACTION and BEGIN WORK in many systems, although the full ANSI-SQL form is START TRANSACTION. Modern engines let you add options such as isolation level, read-write mode, or deferrable constraints directly after BEGIN. If the session is already inside a transaction, issuing BEGIN may raise an error (PostgreSQL) or silently nest (SQL Server “savepoints”). Some dialects (MySQL) reserve BEGIN for procedure blocks; for transactions use START TRANSACTION or BEGIN WORK instead.
WORK
(TRANSACTION) - optional keywords accepted for readabilityISOLATION LEVEL
(string) - sets transaction isolation modeREAD WRITE
(READ ONLY) - keyword|||limits write capability inside transactionDEFERRABLE
(NOT DEFERRABLE) - keyword|||controls constraint evaluation timingPostgreSQL 6.5 (1999)
All three forms start a transaction. They are synonyms in PostgreSQL, SQL Server, and many others. The shorter BEGIN is most common.
No. Locks are taken only when later DML statements run, and the scope depends on the operation and isolation level.
Issue ROLLBACK to revert all changes made since BEGIN.
Most engines require isolation level to be set in the BEGIN statement itself. Setting it later has no effect in PostgreSQL.