{"Entry":{"collection":"sql","key":"commit-prepared","name":"COMMIT PREPARED","aliases":["commit-prepared"],"metadata":{"aliases":["commit-prepared"],"changed_in":[],"changes":[{"from":"8.0","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"8.1"},{"from":"9.1","purpose_changed":false,"renamed":null,"sections":{"added":["compatibility"],"changed":[],"removed":[]},"status":"changed","synopsis":null,"to":"9.2"}],"content_hash":"1f1829544140ae03d91a0419a186cd80c1528bb427d9d4dcbaf5ba0a06223f60","editorial":{},"first_version":"8.1","group":"transaction","imported_at":"2026-09-30T17:43:39.359832+08:00","last_version":"20","name":"COMMIT PREPARED","object":"PREPARED","position":13008,"present_in":["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":"commit a transaction that was earlier prepared for two-phase commit","purpose_zh":"","related":["prepare-transaction","rollback-prepared"],"slug":"commit-prepared","source_rev":"a709ab85","synopsis":"COMMIT PREPARED transaction_id","verb":"COMMIT"}},"Definition":{"Collection":"sql","Key":"commit-prepared","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"commit-prepared","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-COMMIT-PREPARED","file":"sql-commit-prepared.html","lang":"en","name":"COMMIT PREPARED","purpose":"commit a transaction that was earlier prepared for two-phase commit","purpose_zh":"","related":["prepare-transaction","rollback-prepared"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCOMMIT PREPARED\u003c/code\u003e commits a transaction that is in prepared state.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe transaction identifier of the transaction that is to be committed.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eTo commit a prepared transaction, you must be either the same user that executed the transaction originally, or a superuser. But you do not have to be in the same session that executed the transaction.\u003c/p\u003e\u003cp\u003eThis command cannot be executed inside a transaction block. The prepared transaction is committed immediately.\u003c/p\u003e\u003cp\u003eAll currently available prepared transactions are listed in the \u003ca href=\"/docs/18/view-pg-prepared-xacts.html\" title=\"53.17. pg_prepared_xacts\"\u003e\u003ccode class=\"structname\"\u003epg_prepared_xacts\u003c/code\u003e\u003c/a\u003e system view.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eCommit the transaction identified by the transaction identifier \u003ccode class=\"literal\"\u003efoobar\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCOMMIT PREPARED 'foobar';\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCOMMIT PREPARED\u003c/code\u003e is a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extension. It is intended for use by external transaction management systems, some of which are covered by standards (such as X/Open XA), but the SQL side of those systems is not standardized.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/prepare-transaction/?v=18\" title=\"PREPARE TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/rollback-prepared/?v=18\" title=\"ROLLBACK PREPARED\"\u003e\u003cspan class=\"refentrytitle\"\u003eROLLBACK PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"COMMIT PREPARED \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e","synopsis_text":"COMMIT PREPARED transaction_id"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"commit-prepared","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"COMMIT PREPARED","Summary":"提交一个先前为两阶段提交而预备的事务","BodyHTML":"\u003cpre\u003eCOMMIT PREPARED transaction_id\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCOMMIT PREPARED\u003c/code\u003e提交一个处于预备状态的事务。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e要提交的事务的事务标识符。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e要提交预备事务，执行者必须是最初执行该事务的同一用户，或者是超级用户；但不必处在执行该事务的同一会话中。\u003c/p\u003e\u003cp\u003e这个命令不能在事务块内执行。该预备事务会被立即提交。\u003c/p\u003e\u003cp\u003e当前所有处于预备状态的事务都列在 \u003ca href=\"/docs/18/view-pg-prepared-xacts.html\" rel=\"nofollow\"\u003e\u003ccode\u003epg_prepared_xacts\u003c/code\u003e\u003c/a\u003e 系统视图中。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e提交事务标识符为\u003ccode\u003efoobar\u003c/code\u003e的事务：\u003c/p\u003e\u003cpre\u003eCOMMIT PREPARED \u0026#39;foobar\u0026#39;;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCOMMIT PREPARED\u003c/code\u003e是 \u003cspan\u003ePostgreSQL\u003c/span\u003e扩展。它旨在供外部事务管理系统使用，其中有些系统已被标准覆盖（例如 X/Open XA），但这些系统的 SQL 侧并未标准化。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/prepare-transaction/?v=18\" title=\"PREPARE TRANSACTION\" rel=\"nofollow\"\u003e\u003cspan\u003ePREPARE TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/rollback-prepared/?v=18\" title=\"ROLLBACK PREPARED\" rel=\"nofollow\"\u003e\u003cspan\u003eROLLBACK PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"acb902a6232216a942a158e6f474d4678d665ba25a4763c9270592a750a56d9a","Payload":{"purpose_zh":"提交一个先前为两阶段提交而预备的事务","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCOMMIT PREPARED\u003c/code\u003e提交一个处于预备状态的事务。\u003c/p\u003e","key":"description","title":"描述"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e要提交的事务的事务标识符。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"参数"},{"html":"\u003cp\u003e要提交预备事务，执行者必须是最初执行该事务的同一用户，或者是超级用户；但不必处在执行该事务的同一会话中。\u003c/p\u003e\u003cp\u003e这个命令不能在事务块内执行。该预备事务会被立即提交。\u003c/p\u003e\u003cp\u003e当前所有处于预备状态的事务都列在 \u003ca href=\"/docs/18/view-pg-prepared-xacts.html\" title=\"53.17. pg_prepared_xacts\"\u003e\u003ccode class=\"structname\"\u003epg_prepared_xacts\u003c/code\u003e\u003c/a\u003e 系统视图中。\u003c/p\u003e","key":"notes","title":"注解"},{"html":"\u003cp\u003e提交事务标识符为\u003ccode class=\"literal\"\u003efoobar\u003c/code\u003e的事务：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCOMMIT PREPARED 'foobar';\n\u003c/pre\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCOMMIT PREPARED\u003c/code\u003e是 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e扩展。它旨在供外部事务管理系统使用，其中有些系统已被标准覆盖（例如 X/Open XA），但这些系统的 SQL 侧并未标准化。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/prepare-transaction/?v=18\" title=\"PREPARE TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/rollback-prepared/?v=18\" title=\"ROLLBACK PREPARED\"\u003e\u003cspan class=\"refentrytitle\"\u003eROLLBACK PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"COMMIT PREPARED \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e","synopsis_text":"COMMIT PREPARED transaction_id"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","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}
