BEGIN

Name

BEGIN  --  Begins a transaction in chained mode トランザクションを連鎖モードで開始する

Synopsis

  
BEGIN [ WORK | TRANSACTION ]
  

入力

None.

なし。

出力

BEGIN

This signifies that a new transaction has been started.

これは新しいトランザクションが開始されたことを意味します。

NOTICE: BeginTransactionBlock and not in default state

This indicates that a transaction was already in progress. The current transaction is not affected.

これはトランザクションがすでに進行中であることを示します。

説明

By default, Postgres executes transactions in unchained mode (also known as "autocommit" in other database systems). In other words, each user statement is executed in its own transaction and a commit is implicitly performed at the end of the statement (if execution was successful, otherwise a rollback is done). BEGIN initiates a user transaction in chained mode, i.e. all user statements after BEGIN command will be executed in a single transaction until an explicit COMMIT, ROLLBACK or execution abort. Statements in chained mode are executed much faster, because transaction start/commit requires significant CPU and disk activity. Execution of multiple statements inside a transaction is also required for consistency when changing several related tables.

デフォルトでは、Postgres は トランザクションを非連鎖モード (他のデータベースシステムでは"自動コミット" としても知られています) で実行します。 別の言葉で言えば、それぞれのユーザの文はそれ固有のトランザクション の中で実行され、コミットはその文の終わりに暗黙的に実行されます (実行が成功した場合であり、そうでない場合はロールバックされます)。 BEGIN はユーザのトランザクションを連鎖モードで 開始します。すなわち、BEGIN コマンド以降の 全てのユーザの文は、明示的なCOMMIT、ROLLBACK もしくは実行の アボートまでの単一のトランザクションにおいて実行されます。連鎖 モードにおける文はとても迅速に実行されます。なぜなら トランザクションの開始/コミットはとても大きなCPUとディスクの 活動を必要とするからです。トランザクション中の複数の文の 実行はまた、複数の関連する表を更新する時には一貫性が要求されます。

The default transaction isolation level in Postgres is READ COMMITTED, where queries inside the transaction see only changes committed before query execution. So, you have to use SET TRANSACTION ISOLATION LEVEL SERIALIZABLE just after BEGIN if you need more rigorous transaction isolation. In SERIALIZABLE mode queries will see only changes committed before the entire transaction began (actually, before execution of the first DML statement in a serializable transaction).

Postgres におけるデフォルトの トランザクション隔離レベルは、 トランザクション内の問い合わせが問い合わせ実行前にコミット された変更のみが見えるREAD COMMITTED です。 したがって、もしもっと厳しいトランザクションの隔離を必要とする ならば、BEGIN のすぐ後に SET TRANSACTION ISOLATION LEVEL SERIALIZABLE を使わなければなりません。 SERIALIZABLE モードでは、問い合わせはトランザクションの全体が開始 される以前にコミットされた変更のみを参照します (実際には、直列可能なトランザクション中の最初のDML 文の実行以前)。

If the transaction is committed, Postgres will ensure either that all updates are done or else that none of them are done. Transactions have the standard ACID (atomic, consistent, isolatable, and durable) property.

もしトランザクションがコミットされたら、 Postgres は全ての更新がなされるか、 もしくは更新の全てが無効になることを保証します。 トランザクションには、標準のACID 性 (atomic(原子性), consistent(一貫性), isolatable(独立性), durable(持続性)) があります。

注意事項

The keyword TRANSACTION is just a cosmetic alternative to WORK. Neither keyword need be specified.

キーワード TRANSACTION は、WORK に代替する表面的なものです。 どちらのキーワードも指定する必要はありません。

Refer to the LOCK statement for further information about locking tables inside a transaction.

トランザクション中での表のロックに関する更なる情報は、 LOCK 文を参照。

Use COMMIT or ROLLBACK to terminate a transaction.

トランザクションを終了するには、 COMMIT もしくは ROLLBACK を使用すること。

使用法

To begin a user transaction:

ユーザトランザクションを開始する:

BEGIN WORK;
  

互換性

BEGIN is a Postgres language extension.

BEGIN は、Postgres の言語拡張です。

SQL92

There is no explicit BEGIN WORK command in SQL92; transaction initiation is always implicit and it terminates either with a COMMIT or with a ROLLBACK statement.

SQL92 には、明示的なBEGIN WORK コマンドはありま せん。トランザクションの開始はいつも暗黙的であり、COMMIT または ROLLBACK 文で終了します。

Note: Many relational database systems offer an autocommit feature as a convenience.

多くの関係データベースシステムは、便宜上、自動コミットの機能を 提供します。

SQL92 also requires SERIALIZABLE to be the default transaction isolation level.

SQL92 はまた、SERIALIZABLE をデフォルトの トランザクション隔離レベルとして要求します。