{"Entry":{"collection":"sql","key":"begin","name":"BEGIN","aliases":["beginwork","begin"],"metadata":{"aliases":["beginwork","begin"],"changed_in":["8.0","9.0","9.1"],"changes":[{"from":"6.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"6.5"},{"from":"6.5","purpose_changed":false,"renamed":{"from_file":"sql-beginwork.htm","to_file":"sql-begin.htm"},"sections":{"added":[],"changed":["description","compatibility"],"removed":[]},"status":"changed","synopsis":null,"to":"7.0"},{"from":"7.0","purpose_changed":false,"renamed":{"from_file":"sql-begin.htm","to_file":"sql-begin.html"},"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"7.1"},{"from":"7.1","purpose_changed":true,"renamed":null,"sections":{"added":[],"changed":["description","compatibility"],"removed":[]},"status":"changed","synopsis":null,"to":"7.2"},{"from":"7.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"7.3"},{"from":"7.3","purpose_changed":false,"renamed":null,"sections":{"added":["parameters","notes","examples","see_also"],"changed":["description","compatibility"],"removed":["usage"]},"status":"changed","synopsis":null,"to":"7.4"},{"from":"7.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","parameters","notes","compatibility","see_also"],"removed":[]},"status":"changed","synopsis":{"added":["BEGIN [ WORK | TRANSACTION ] [ transaction_mode [, ...] ]","where transaction_mode is one of:","ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }","READ WRITE | READ ONLY"],"removed":[]},"to":"8.0"},{"from":"8.1","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["compatibility"],"removed":[]},"status":"changed","synopsis":null,"to":"8.2"},{"from":"8.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":null,"to":"8.3"},{"from":"8.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"changed","synopsis":{"added":[],"removed":["where transaction_mode is one of:"]},"to":"9.0"},{"from":"9.0","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","compatibility"],"removed":[]},"status":"changed","synopsis":{"added":["[ NOT ] DEFERRABLE"],"removed":[]},"to":"9.1"},{"from":"9.6","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description"],"removed":[]},"status":"changed","synopsis":null,"to":"10"}],"content_hash":"37ee0e395696178292eb73b1415c1a2c6536e93233d42ac3341fafb9f09737d6","editorial":{},"first_version":"6.5","group":"transaction","imported_at":"2026-09-30T17:43:39.311602+08:00","last_version":"20","name":"BEGIN","object":"","position":13001,"present_in":["6.5","7.0","7.1","7.2","7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"purpose":"start a transaction block","purpose_zh":"","related":["commit","rollback","start-transaction","savepoint"],"slug":"begin","source_rev":"a709ab85","synopsis":"BEGIN [ WORK | TRANSACTION ] [ transaction_mode [, ...] ]\n\nwhere transaction_mode is one of:\n\nISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }\nREAD WRITE | READ ONLY\n[ NOT ] DEFERRABLE","verb":"BEGIN"}},"Definition":{"Collection":"sql","Key":"begin","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"begin","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-BEGIN","file":"sql-begin.html","lang":"en","name":"BEGIN","purpose":"start a transaction block","purpose_zh":"","related":["commit","rollback","start-transaction","savepoint"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e initiates a transaction block, that is, all statements after a \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e command will be executed in a single transaction until an explicit \u003ca href=\"/docs/18/sql-commit.html\" title=\"COMMIT\"\u003e\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e\u003c/a\u003e or \u003ca href=\"/docs/18/sql-rollback.html\" title=\"ROLLBACK\"\u003e\u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e\u003c/a\u003e is given. By default (without \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e), \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e executes transactions in \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eautocommit\u003c/span\u003e”\u003c/span\u003e mode, that is, each 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).\u003c/p\u003e\u003cp\u003eStatements are executed more quickly in a transaction block, because transaction start/commit requires significant CPU and disk activity. Execution of multiple statements inside a transaction is also useful to ensure consistency when making several related changes: other sessions will be unable to see the intermediate states wherein not all the related updates have been done.\u003c/p\u003e\u003cp\u003eIf the isolation level, read/write mode, or deferrable mode is specified, the new transaction has those characteristics, as if \u003ca href=\"/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\"\u003e\u003ccode class=\"command\"\u003eSET TRANSACTION\u003c/code\u003e\u003c/a\u003e was executed.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eWORK\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eTRANSACTION\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eOptional key words. They have no effect.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003eRefer to \u003ca href=\"/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eSET TRANSACTION\u003c/span\u003e\u003c/a\u003e for information on the meaning of the other parameters to this statement.\u003c/p\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003e\u003ca href=\"/docs/18/sql-start-transaction.html\" title=\"START TRANSACTION\"\u003e\u003ccode class=\"command\"\u003eSTART TRANSACTION\u003c/code\u003e\u003c/a\u003e has the same functionality as \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e.\u003c/p\u003e\u003cp\u003eUse \u003ca href=\"/docs/18/sql-commit.html\" title=\"COMMIT\"\u003e\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e\u003c/a\u003e or \u003ca href=\"/docs/18/sql-rollback.html\" title=\"ROLLBACK\"\u003e\u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e\u003c/a\u003e to terminate a transaction block.\u003c/p\u003e\u003cp\u003eIssuing \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e when already inside a transaction block will provoke a warning message. The state of the transaction is not affected. To nest transactions within a transaction block, use savepoints (see \u003ca href=\"/docs/18/sql-savepoint.html\" title=\"SAVEPOINT\"\u003e\u003cspan class=\"refentrytitle\"\u003eSAVEPOINT\u003c/span\u003e\u003c/a\u003e).\u003c/p\u003e\u003cp\u003eFor reasons of backwards compatibility, the commas between successive \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_modes\u003c/code\u003e\u003c/em\u003e can be omitted.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eTo begin a transaction block:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eBEGIN;\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e language extension. It is equivalent to the SQL-standard command \u003ca href=\"/docs/18/sql-start-transaction.html\" title=\"START TRANSACTION\"\u003e\u003ccode class=\"command\"\u003eSTART TRANSACTION\u003c/code\u003e\u003c/a\u003e, whose reference page contains additional compatibility information.\u003c/p\u003e\u003cp\u003eThe \u003ccode class=\"literal\"\u003eDEFERRABLE\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_mode\u003c/code\u003e\u003c/em\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e language extension.\u003c/p\u003e\u003cp\u003eIncidentally, the \u003ccode class=\"literal\"\u003eBEGIN\u003c/code\u003e key word is used for a different purpose in embedded SQL. You are advised to be careful about the transaction semantics when porting database applications.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/commit/?v=18\" title=\"COMMIT\"\u003e\u003cspan class=\"refentrytitle\"\u003eCOMMIT\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/rollback/?v=18\" title=\"ROLLBACK\"\u003e\u003cspan class=\"refentrytitle\"\u003eROLLBACK\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/start-transaction/?v=18\" title=\"START TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eSTART TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/savepoint/?v=18\" title=\"SAVEPOINT\"\u003e\u003cspan class=\"refentrytitle\"\u003eSAVEPOINT\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"BEGIN [ WORK | TRANSACTION ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_mode\u003c/code\u003e\u003c/em\u003e [, ...] ]\n\n\u003cspan class=\"phrase\"\u003ewhere \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_mode\u003c/code\u003e\u003c/em\u003e is one of:\u003c/span\u003e\n\n    ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }\n    READ WRITE | READ ONLY\n    [ NOT ] DEFERRABLE","synopsis_text":"BEGIN [ WORK | TRANSACTION ] [ transaction_mode [, ...] ]\n\nwhere transaction_mode is one of:\n\nISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }\nREAD WRITE | READ ONLY\n[ NOT ] DEFERRABLE"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"begin","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"BEGIN","Summary":"开始一个事务块","BodyHTML":"\u003cpre\u003eBEGIN [ WORK | TRANSACTION ] [ transaction_mode [, ...] ]\n\n其中 transaction_mode 是下列之一：\n\nISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }\nREAD WRITE | READ ONLY\n[ NOT ] DEFERRABLE\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eBEGIN\u003c/code\u003e启动一个事务块，也就是说，在 \u003ccode\u003eBEGIN\u003c/code\u003e命令之后的所有语句都会在同一个事务中执行，直到显式给出\u003ca href=\"/docs/18/sql-commit.html\" title=\"COMMIT\" rel=\"nofollow\"\u003e\u003ccode\u003eCOMMIT\u003c/code\u003e\u003c/a\u003e或 \u003ca href=\"/docs/18/sql-rollback.html\" title=\"ROLLBACK\" rel=\"nofollow\"\u003e\u003ccode\u003eROLLBACK\u003c/code\u003e\u003c/a\u003e为止。默认情况下（不使用\u003ccode\u003eBEGIN\u003c/code\u003e），\u003cspan\u003ePostgreSQL\u003c/span\u003e以\u003cspan\u003e“\u003cspan\u003e自动提交\u003c/span\u003e”\u003c/span\u003e模式执行事务，也就是说，每条语句都在自己的事务中执行，并在语句结束时隐式提交（如果执行成功，否则回滚）。\u003c/p\u003e\u003cp\u003e在事务块中执行语句通常会更快，因为事务的启动和提交需要大量的 CPU 和磁盘活动。在进行多个相关更改时，把多条语句放在一个事务中执行也有助于保证一致性：其他会话将无法看到那些相关更新尚未全部完成时的中间状态。\u003c/p\u003e\u003cp\u003e如果指定了隔离级别、读写模式或可延迟模式，新事务就会具有这些特征，就像执行了 \u003ca href=\"/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\" rel=\"nofollow\"\u003e\u003ccode\u003eSET TRANSACTION\u003c/code\u003e\u003c/a\u003e一样。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eWORK\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003eTRANSACTION\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e可选关键字，没有任何作用。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e关于本语句其他参数含义的信息，参见\u003ca href=\"/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\" rel=\"nofollow\"\u003e\u003cspan\u003eSET TRANSACTION\u003c/span\u003e\u003c/a\u003e。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e\u003ca href=\"/docs/18/sql-start-transaction.html\" title=\"START TRANSACTION\" rel=\"nofollow\"\u003e\u003ccode\u003eSTART TRANSACTION\u003c/code\u003e\u003c/a\u003e 与\u003ccode\u003eBEGIN\u003c/code\u003e具有相同功能。\u003c/p\u003e\u003cp\u003e使用\u003ca href=\"/docs/18/sql-commit.html\" title=\"COMMIT\" rel=\"nofollow\"\u003e\u003ccode\u003eCOMMIT\u003c/code\u003e\u003c/a\u003e或 \u003ca href=\"/docs/18/sql-rollback.html\" title=\"ROLLBACK\" rel=\"nofollow\"\u003e\u003ccode\u003eROLLBACK\u003c/code\u003e\u003c/a\u003e 可以结束一个事务块。\u003c/p\u003e\u003cp\u003e如果在已经处于事务块中时发出\u003ccode\u003eBEGIN\u003c/code\u003e，将会产生一条警告消息。事务状态不会受影响。若要在事务块中实现事务嵌套，请使用保存点（参见\u003ca href=\"/docs/18/sql-savepoint.html\" title=\"SAVEPOINT\" rel=\"nofollow\"\u003e\u003cspan\u003eSAVEPOINT\u003c/span\u003e\u003c/a\u003e）。\u003c/p\u003e\u003cp\u003e出于向后兼容的考虑，连续多个\u003cem\u003e\u003ccode\u003etransaction_modes\u003c/code\u003e\u003c/em\u003e 之间的逗号可以省略。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e开始一个事务块：\u003c/p\u003e\u003cpre\u003eBEGIN;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eBEGIN\u003c/code\u003e是\u003cspan\u003ePostgreSQL\u003c/span\u003e的一种语言扩展。它等价于 SQL 标准命令 \u003ca href=\"/docs/18/sql-start-transaction.html\" title=\"START TRANSACTION\" rel=\"nofollow\"\u003e\u003ccode\u003eSTART TRANSACTION\u003c/code\u003e\u003c/a\u003e，后者的参考页中包含更多兼容性信息。\u003c/p\u003e\u003cp\u003e\u003ccode\u003eDEFERRABLE\u003c/code\u003e \u003cem\u003e\u003ccode\u003etransaction_mode\u003c/code\u003e\u003c/em\u003e 是\u003cspan\u003ePostgreSQL\u003c/span\u003e的一种语言扩展。\u003c/p\u003e\u003cp\u003e另外，在嵌入式 SQL 中，关键字\u003ccode\u003eBEGIN\u003c/code\u003e用于不同的目的。在移植数据库应用程序时，应当谨慎处理事务语义。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/commit/?v=18\" title=\"COMMIT\" rel=\"nofollow\"\u003e\u003cspan\u003eCOMMIT\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/rollback/?v=18\" title=\"ROLLBACK\" rel=\"nofollow\"\u003e\u003cspan\u003eROLLBACK\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/start-transaction/?v=18\" title=\"START TRANSACTION\" rel=\"nofollow\"\u003e\u003cspan\u003eSTART TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/savepoint/?v=18\" title=\"SAVEPOINT\" rel=\"nofollow\"\u003e\u003cspan\u003eSAVEPOINT\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"29fa9acd794e1c2f9c6cd2f83885b3e700b76219149de64e9a97e04568658785","Payload":{"purpose_zh":"开始一个事务块","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e启动一个事务块，也就是说，在 \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e命令之后的所有语句都会在同一个事务中执行，直到显式给出\u003ca href=\"/docs/18/sql-commit.html\" title=\"COMMIT\"\u003e\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e\u003c/a\u003e或 \u003ca href=\"/docs/18/sql-rollback.html\" title=\"ROLLBACK\"\u003e\u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e\u003c/a\u003e为止。默认情况下（不使用\u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e），\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e以\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e自动提交\u003c/span\u003e”\u003c/span\u003e模式执行事务，也就是说，每条语句都在自己的事务中执行，并在语句结束时隐式提交（如果执行成功，否则回滚）。\u003c/p\u003e\u003cp\u003e在事务块中执行语句通常会更快，因为事务的启动和提交需要大量的 CPU 和磁盘活动。在进行多个相关更改时，把多条语句放在一个事务中执行也有助于保证一致性：其他会话将无法看到那些相关更新尚未全部完成时的中间状态。\u003c/p\u003e\u003cp\u003e如果指定了隔离级别、读写模式或可延迟模式，新事务就会具有这些特征，就像执行了 \u003ca href=\"/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\"\u003e\u003ccode class=\"command\"\u003eSET TRANSACTION\u003c/code\u003e\u003c/a\u003e一样。\u003c/p\u003e","key":"description","title":"描述"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eWORK\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eTRANSACTION\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e可选关键字，没有任何作用。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e关于本语句其他参数含义的信息，参见\u003ca href=\"/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eSET TRANSACTION\u003c/span\u003e\u003c/a\u003e。\u003c/p\u003e","key":"parameters","title":"参数"},{"html":"\u003cp\u003e\u003ca href=\"/docs/18/sql-start-transaction.html\" title=\"START TRANSACTION\"\u003e\u003ccode class=\"command\"\u003eSTART TRANSACTION\u003c/code\u003e\u003c/a\u003e 与\u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e具有相同功能。\u003c/p\u003e\u003cp\u003e使用\u003ca href=\"/docs/18/sql-commit.html\" title=\"COMMIT\"\u003e\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e\u003c/a\u003e或 \u003ca href=\"/docs/18/sql-rollback.html\" title=\"ROLLBACK\"\u003e\u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e\u003c/a\u003e 可以结束一个事务块。\u003c/p\u003e\u003cp\u003e如果在已经处于事务块中时发出\u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e，将会产生一条警告消息。事务状态不会受影响。若要在事务块中实现事务嵌套，请使用保存点（参见\u003ca href=\"/docs/18/sql-savepoint.html\" title=\"SAVEPOINT\"\u003e\u003cspan class=\"refentrytitle\"\u003eSAVEPOINT\u003c/span\u003e\u003c/a\u003e）。\u003c/p\u003e\u003cp\u003e出于向后兼容的考虑，连续多个\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_modes\u003c/code\u003e\u003c/em\u003e 之间的逗号可以省略。\u003c/p\u003e","key":"notes","title":"注解"},{"html":"\u003cp\u003e开始一个事务块：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eBEGIN;\n\u003c/pre\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e是\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e的一种语言扩展。它等价于 SQL 标准命令 \u003ca href=\"/docs/18/sql-start-transaction.html\" title=\"START TRANSACTION\"\u003e\u003ccode class=\"command\"\u003eSTART TRANSACTION\u003c/code\u003e\u003c/a\u003e，后者的参考页中包含更多兼容性信息。\u003c/p\u003e\u003cp\u003e\u003ccode class=\"literal\"\u003eDEFERRABLE\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_mode\u003c/code\u003e\u003c/em\u003e 是\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e的一种语言扩展。\u003c/p\u003e\u003cp\u003e另外，在嵌入式 SQL 中，关键字\u003ccode class=\"literal\"\u003eBEGIN\u003c/code\u003e用于不同的目的。在移植数据库应用程序时，应当谨慎处理事务语义。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/commit/?v=18\" title=\"COMMIT\"\u003e\u003cspan class=\"refentrytitle\"\u003eCOMMIT\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/rollback/?v=18\" title=\"ROLLBACK\"\u003e\u003cspan class=\"refentrytitle\"\u003eROLLBACK\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/start-transaction/?v=18\" title=\"START TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eSTART TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/savepoint/?v=18\" title=\"SAVEPOINT\"\u003e\u003cspan class=\"refentrytitle\"\u003eSAVEPOINT\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"BEGIN [ WORK | TRANSACTION ] [ \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_mode\u003c/code\u003e\u003c/em\u003e [, ...] ]\n\n\u003cspan class=\"phrase\"\u003e其中 \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_mode\u003c/code\u003e\u003c/em\u003e 是下列之一：\u003c/span\u003e\n\n    ISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }\n    READ WRITE | READ ONLY\n    [ NOT ] DEFERRABLE","synopsis_text":"BEGIN [ WORK | TRANSACTION ] [ transaction_mode [, ...] ]\n\n其中 transaction_mode 是下列之一：\n\nISOLATION LEVEL { SERIALIZABLE | REPEATABLE READ | READ COMMITTED | READ UNCOMMITTED }\nREAD WRITE | READ ONLY\n[ NOT ] DEFERRABLE"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","6.5","7.0","7.1","7.2","7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
