Starts a transaction block.
START TRANSACTION [SERIALIZABLE | READ COMMITTED | READ UNCOMMITTED]
[READ WRITE | READ ONLY]
START TRANSACTION
begins a new transaction block. If the isolation level or read/write mode is specified, the new transaction has those characteristics, as if SET TRANSACTION was executed. This is the same as the BEGIN
command.
READ COMMITTED
,
READ UNCOMMITTED
,
SERIALIZABLE
, and
REPEATABLE READ
. The default behavior is that a statement can only see rows committed before it began (
READ COMMITTED
). In Greenplum Database
READ UNCOMMITTED
is treated the same as
READ COMMITTED
.
REPEATABLE READ
is not supported; use
SERIALIZABLE
if this behavior is required.
SERIALIZABLE
, wherein all statements of the current transaction can only see rows committed before the first statement was executed in the transaction, is the strictest transaction isolation. This level emulates serial transaction execution, as if transactions had been executed one after another, serially, rather than concurrently. Applications using this level must be prepared to retry transactions due to serialization failures.
INSERT
,
UPDATE
,
DELETE
, and
COPY FROM
if the table they would write to is not a temporary table; all
CREATE
,
ALTER
, and
DROP
commands;
GRANT
,
REVOKE
,
TRUNCATE
; and
EXPLAIN ANALYZE
and
EXECUTE
if the command they would execute is among those listed.
To begin a transaction block:
START TRANSACTION;
In the standard, it is not necessary to issue START TRANSACTION
to start a transaction block: any SQL command implicitly begins a block. Greenplum Database behavior can be seen as implicitly issuing a COMMIT
after each command that does not follow START TRANSACTION
(or BEGIN
), and it is therefore often called 'autocommit'. Other relational database systems may offer an autocommit feature as a convenience.
The SQL standard requires commas between successive transaction_modes, but for historical reasons Greenplum Database allows the commas to be omitted.
See also the compatibility section of SET TRANSACTION.
Parent topic: SQL Command Reference