Postgresql 中文操作指南

START TRANSACTION

START TRANSACTION — 开始一个事务块

START TRANSACTION — start a transaction block

Synopsis

START 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

此命令开始一个新的事务块。如果指定了隔离级别、读写模式或可延期模式,则新事务将具有这些特性,就像执行了 SET TRANSACTION 。这与 BEGIN 命令相同。

This command begins a new transaction block. If the isolation level, read/write mode, or deferrable mode is specified, the new transaction has those characteristics, as if SET TRANSACTION was executed. This is the same as the BEGIN command.

Parameters

有关此语句的参数含义的信息,请参阅 SET TRANSACTION

Refer to SET TRANSACTION for information on the meaning of the parameters to this statement.

Compatibility

在标准中,不必发出 START TRANSACTION 来启动事务块:任何 SQL 命令都会隐式地开始一个块。PostgreSQL 的行为可以看作是在每个不遵循 START TRANSACTION (或 BEGIN )的命令后隐式发出 COMMIT ,因此它通常称为“自动提交”。其他关系数据库系统可能提供自动提交功能作为一种便利。

In the standard, it is not necessary to issue START TRANSACTION to start a transaction block: any SQL command implicitly begins a block. PostgreSQL’s 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 might offer an autocommit feature as a convenience.

DEFERRABLE transaction_mode 是 PostgreSQL 语言扩展。

The DEFERRABLE transaction_mode is a PostgreSQL language extension.

SQL 标准要求在连续的 transaction_modes 之间使用逗号,但出于历史原因,PostgreSQL 允许省略逗号。

The SQL standard requires commas between successive transaction_modes, but for historical reasons PostgreSQL allows the commas to be omitted.

另请参阅 SET TRANSACTION 的兼容性部分。

See also the compatibility section of SET TRANSACTION.