{"Entry":{"collection":"sql","key":"rollback-prepared","name":"ROLLBACK PREPARED","aliases":["rollback-prepared"],"metadata":{"aliases":["rollback-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":"0c108378048047d209cdbe32a9b208cd80aa53c9d0dd4425780038c57db56b90","derived_content_hash":"4de49999b571146dc2887dce986ba2c9caef07ebf0d22ec6f653ba729636c94a","editorial":{},"first_version":"8.1","group":"transaction","imported_at":"2026-09-30T17:43:39.365243+08:00","last_version":"20","name":"ROLLBACK PREPARED","object":"PREPARED","position":13009,"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":"cancel a transaction that was earlier prepared for two-phase commit","purpose_zh":"","related":["prepare-transaction","commit-prepared"],"repair_provenance":{"original_source_revision":"wiki-repair-20261023:534706aded84c203eab5a09bf9ff1be368944add1c6c7581176bc14e40f34f20","receipt_sha256":"3586da43efbed45d77686f37082931ac3db8b2eabd549057cab1c53eec21e0ce","repair":"wiki-repair-20261023"},"slug":"rollback-prepared","source_rev":"wiki-repair-20261023:781c51a937027ecdb0ada27339bd70c7d2442ec7ae44959d77cf9e8f6c32bdfa","synopsis":"ROLLBACK PREPARED transaction_id","verb":"ROLLBACK"}},"Definition":{"Collection":"sql","Key":"rollback-prepared","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"rollback-prepared","SourceRevision":"wiki-repair-20261023:781c51a937027ecdb0ada27339bd70c7d2442ec7ae44959d77cf9e8f6c32bdfa","Facts":{"anchor":"SQL-ROLLBACK-PREPARED","description_zh":"回滚一个先前为两阶段提交而预备的事务","description_zh_html":"\u003cpre\u003eROLLBACK PREPARED transaction_id\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eROLLBACK PREPARED\u003c/code\u003e 回滚一个处于预备状态的事务。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\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\n      要回滚的事务的事务标识符。\n     \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e\n   要回滚预备事务，执行者必须是最初执行该事务的同一用户，或者是超级用户；但不必处在执行该事务的同一会话中。\n  \u003c/p\u003e\u003cp\u003e\n   这个命令不能在事务块内执行。该预备事务会被立即回滚。\n  \u003c/p\u003e\u003cp\u003e\n   当前所有处于预备状态的事务都列在\n   \u003ca class=\"link\" href=\"/zh/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\n   系统视图中。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e\n   回滚事务标识符为 \u003ccode class=\"literal\"\u003efoobar\u003c/code\u003e 的事务：\n\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nROLLBACK PREPARED 'foobar';\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eROLLBACK PREPARED\u003c/code\u003e 是\n   \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 扩展。它旨在供外部事务管理系统使用，其中有些系统已被标准覆盖（例如 X/Open XA），但这些系统的 SQL 侧并未标准化。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/zh/docs/18/sql-prepare-transaction.html\" title=\"PREPARE TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003ePREPARE TRANSACTION\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/sql-commit-prepared.html\" title=\"COMMIT PREPARED\"\u003e\u003cspan class=\"refentrytitle\"\u003eCOMMIT PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","file":"sql-rollback-prepared.html","lang":"en","name":"ROLLBACK PREPARED","purpose":"cancel a transaction that was earlier prepared for two-phase commit","purpose_zh":"回滚一个先前为两阶段提交而预备的事务","related":["prepare-transaction","commit-prepared"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eROLLBACK PREPARED\u003c/code\u003e rolls back 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 rolled back.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eTo roll back 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 rolled back 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\u003eRoll back the transaction identified by the transaction identifier \u003ccode class=\"literal\"\u003efoobar\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eROLLBACK PREPARED 'foobar';\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eROLLBACK 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/commit-prepared/?v=18\" title=\"COMMIT PREPARED\"\u003e\u003cspan class=\"refentrytitle\"\u003eCOMMIT PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"ROLLBACK PREPARED \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e","synopsis_text":"ROLLBACK PREPARED transaction_id","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/sql-rollback-prepared.html","sha256":"5240538b6fb2ed5bb39370e54ec0aaaa66525d1081e2b5c49f7f369979279ac1"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"zh_from":"same-version-pgdoc"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"rollback-prepared","SourceDatabase":"center","Version":"18","Locale":"en","Title":"ROLLBACK PREPARED","Summary":"cancel a transaction that was earlier prepared for two-phase commit","BodyHTML":"\u003cpre\u003eROLLBACK PREPARED transaction_id\u003c/pre\u003e\u003csection\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eROLLBACK PREPARED\u003c/code\u003e rolls back a transaction that is in prepared state.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eParameters\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\u003eThe transaction identifier of the transaction that is to be rolled back.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eNotes\u003c/h2\u003e\u003cp\u003eTo roll back 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 rolled back immediately.\u003c/p\u003e\u003cp\u003eAll currently available prepared transactions are listed in the \u003ca href=\"/docs/18/view-pg-prepared-xacts.html\" rel=\"nofollow\"\u003e\u003ccode\u003epg_prepared_xacts\u003c/code\u003e\u003c/a\u003e system view.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eExamples\u003c/h2\u003e\u003cp\u003eRoll back the transaction identified by the transaction identifier \u003ccode\u003efoobar\u003c/code\u003e:\u003c/p\u003e\u003cpre\u003eROLLBACK PREPARED \u0026#39;foobar\u0026#39;;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eCompatibility\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eROLLBACK PREPARED\u003c/code\u003e is a \u003cspan\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\u003c/section\u003e\u003csection\u003e\u003ch2\u003eSee Also\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/commit-prepared/?v=18\" title=\"COMMIT PREPARED\" rel=\"nofollow\"\u003e\u003cspan\u003eCOMMIT PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"wiki-repair-20261023:781c51a937027ecdb0ada27339bd70c7d2442ec7ae44959d77cf9e8f6c32bdfa","ContentHash":"cab5705ba52e247a3a870bfa49694ab467a3927afe607122d86590d7593ffead","Payload":{"related":["prepare-transaction","commit-prepared"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eROLLBACK PREPARED\u003c/code\u003e rolls back 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 rolled back.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eTo roll back 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 rolled back 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\u003eRoll back the transaction identified by the transaction identifier \u003ccode class=\"literal\"\u003efoobar\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eROLLBACK PREPARED 'foobar';\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eROLLBACK 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/commit-prepared/?v=18\" title=\"COMMIT PREPARED\"\u003e\u003cspan class=\"refentrytitle\"\u003eCOMMIT PREPARED\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","synopsis_html":"ROLLBACK PREPARED \u003cem class=\"replaceable\"\u003e\u003ccode\u003etransaction_id\u003c/code\u003e\u003c/em\u003e","synopsis_text":"ROLLBACK PREPARED transaction_id"}},"RequestedLocale":"en","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}
