BEGIN

An SQL command for starting a transaction block

BEGIN is a transaction command for starting a transaction block. It is equivalent to the SQL standard START TRANSACTION command.

BEGIN has always been present in PostgreSQL.

Usage

One of the following transaction isolation levels can optionally be specified:

  • READ COMMITTED
  • READ UNCOMMITTED
  • REPEATABLE READ
  • SERIALIZABLE

READ COMMITTED is the default.

Examples

Basic execution example for BEGIN:

postgres=# BEGIN;
BEGIN

A WARNING will be emitted if BEGIN is executed inside an existing transaction:

postgres=# BEGIN;
BEGIN

postgres=*# BEGIN;
WARNING:  there is already a transaction in progress
BEGIN
  • PostgreSQL documentation: BEGIN

Categories

SQL command, Transaction command, Transactions

See also

START TRANSACTION, COMMIT, ROLLBACK, SET TRANSACTION