BEGIN

Starts a transaction block. BEGIN is a synonym for START TRANSACTION.

Syntax

BEGIN [ WORK | TRANSACTION ] [ isolation‑level ] [ transaction‑mode]

and where transaction_mode is one of:

READ { ONLY | WRITE }

Parameters

WORK | TRANSACTION

Optional keywords for readability purposes only.

isolation‑level

Specifies the transaction's isolation level, which determines what data the transaction can access when other transactions are running concurrently. You can set isolation‑level to one of the following:

  • READ COMMITTED (default)
  • SERIALIZABLE
  • REPEATABLE READ (automatically converted to SERIALIZABLE)
  • READ UNCOMMITTED (automatically converted to READ COMMITTED)

For detailed information, see Transactions in Vertica Concepts.

transaction‑mode  
READ { ONLY | WRITE }

Transaction mode can be one of the following:

  • READ WRITE—(default)The transaction is read/write.
  • READ ONLY—The transaction is read-only.

Setting the transaction session mode to read-only disallows the following SQL commands, but does not prevent all disk write operations:

  • INSERT, UPDATE, DELETE, and COPY if the table they would write to is not a temporary table
  • All CREATE, ALTER, and DROP commands
  • GRANT, REVOKE, and EXPLAIN if the command it would run is among those listed.

Privileges

None

Examples

This example shows how to begin a transaction and set the isolation level.

=> BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED READ WRITE;
BEGIN
=> CREATE TABLE sample_table (a INT);
CREATE TABLE
=> INSERT INTO sample_table (a) VALUES (1);
OUTPUT
--------
1
(1 row)