{"Entry":{"collection":"sql","key":"rollback","name":"ROLLBACK","aliases":["rollback"],"metadata":{"aliases":["rollback"],"changed_in":["6.5","12"],"changes":[{"from":"6.4","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","usage","compatibility"],"removed":[]},"status":"changed","synopsis":{"added":["ROLLBACK [ WORK | TRANSACTION ]"],"removed":[]},"to":"6.5"},{"from":"6.5","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["description","compatibility"],"removed":[]},"status":"changed","synopsis":null,"to":"7.0"},{"from":"7.0","purpose_changed":false,"renamed":{"from_file":"sql-rollback.htm","to_file":"sql-rollback.html"},"sections":{"added":[],"changed":[],"removed":[]},"status":"changed","synopsis":null,"to":"7.1"},{"from":"7.1","purpose_changed":true,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"changed","synopsis":null,"to":"7.2"},{"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":["see_also"],"removed":[]},"status":"changed","synopsis":null,"to":"8.0"},{"from":"9.3","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["notes"],"removed":[]},"status":"changed","synopsis":null,"to":"9.4"},{"from":"11","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","notes","compatibility"],"removed":[]},"status":"changed","synopsis":{"added":["ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]"],"removed":[]},"to":"12"},{"from":"15","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":null,"to":"16"}],"content_hash":"992ee35d8007469a1c868f499e94925fe0dea762376817683894693edbfe6855","derived_content_hash":"cc4b3c9c9fed781e68e55b901234bc7b885432c135139ba3b7909fa11a1107f2","editorial":{},"first_version":"6.4","group":"transaction","imported_at":"2026-09-30T17:43:39.33716+08:00","last_version":"20","name":"ROLLBACK","object":"","position":13004,"present_in":["6.4","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":"abort the current transaction","purpose_zh":"","related":["begin","commit","rollback-to-savepoint"],"repair_provenance":{"original_source_revision":"wiki-repair-20261023:b1c1166a614f2b52aebdf36afd6c9ddd4cd0af926d6f977eec63a017179a0ccf","receipt_sha256":"9082acaf4e39ef6de3ecfe548c365a048a2278a7fd589d4de6f03be937a59670","repair":"wiki-repair-20261023"},"slug":"rollback","source_rev":"wiki-repair-20261023:93225a29f342291148b6f0f592fe12e5a74edfeb0a9a68495ebb5ac59bed3546","synopsis":"ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]","verb":"ROLLBACK"}},"Definition":{"Collection":"sql","Key":"rollback","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"rollback","SourceRevision":"wiki-repair-20261023:93225a29f342291148b6f0f592fe12e5a74edfeb0a9a68495ebb5ac59bed3546","Facts":{"anchor":"SQL-ROLLBACK","description_zh":"中止当前事务","description_zh_html":"\u003cpre\u003eROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003ccode class=\"command\"\u003eROLLBACK\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 id=\"SQL-ROLLBACK-TRANSACTION\"\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\n      可选关键字，没有任何作用。\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"SQL-ROLLBACK-CHAIN\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eAND CHAIN\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      如果指定了 \u003ccode class=\"literal\"\u003eAND CHAIN\u003c/code\u003e，则会立即启动一个新的（未中止的）事务，其事务特征与刚刚结束的事务相同（参见 \u003ca class=\"xref\" href=\"/zh/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eSET TRANSACTION\u003c/span\u003e\u003c/a\u003e）。否则，不会启动任何新事务。\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   使用 \u003ca class=\"link\" href=\"/zh/docs/18/sql-commit.html\" title=\"COMMIT\"\u003e\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e\u003c/a\u003e 可成功地终止一个事务。\n  \u003c/p\u003e\u003cp\u003e\n   在事务块之外发出 \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e 不会造成任何影响，但会产生一条警告消息。事务块之外的 \u003ccode class=\"command\"\u003eROLLBACK AND CHAIN\u003c/code\u003e 则会报错。\n  \u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e\n   要中止所有更改：\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nROLLBACK;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\n   命令 \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e 符合 SQL 标准。形式 \u003ccode class=\"literal\"\u003eROLLBACK TRANSACTION\u003c/code\u003e 是 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 扩展。\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-begin.html\" title=\"BEGIN\"\u003e\u003cspan class=\"refentrytitle\"\u003eBEGIN\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/sql-commit.html\" title=\"COMMIT\"\u003e\u003cspan class=\"refentrytitle\"\u003eCOMMIT\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/sql-rollback-to.html\" title=\"ROLLBACK TO SAVEPOINT\"\u003e\u003cspan class=\"refentrytitle\"\u003eROLLBACK TO SAVEPOINT\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","file":"sql-rollback.html","lang":"en","name":"ROLLBACK","purpose":"abort the current transaction","purpose_zh":"中止当前事务","related":["begin","commit","rollback-to-savepoint"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e rolls back the current transaction and causes all the updates made by the transaction to be discarded.\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\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eAND CHAIN\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eIf \u003ccode class=\"literal\"\u003eAND CHAIN\u003c/code\u003e is specified, a new (not aborted) transaction is immediately started with the same transaction characteristics (see \u003ca href=\"/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eSET TRANSACTION\u003c/span\u003e\u003c/a\u003e) as the just finished one. Otherwise, no new transaction is started.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eUse \u003ca href=\"/docs/18/sql-commit.html\" title=\"COMMIT\"\u003e\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e\u003c/a\u003e to successfully terminate a transaction.\u003c/p\u003e\u003cp\u003eIssuing \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e outside of a transaction block emits a warning and otherwise has no effect. \u003ccode class=\"command\"\u003eROLLBACK AND CHAIN\u003c/code\u003e outside of a transaction block is an error.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eTo abort all changes:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eROLLBACK;\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003eThe command \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e conforms to the SQL standard. The form \u003ccode class=\"literal\"\u003eROLLBACK TRANSACTION\u003c/code\u003e is a PostgreSQL extension.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/begin/?v=18\" title=\"BEGIN\"\u003e\u003cspan class=\"refentrytitle\"\u003eBEGIN\u003c/span\u003e\u003c/a\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-to-savepoint/?v=18\" title=\"ROLLBACK TO SAVEPOINT\"\u003e\u003cspan class=\"refentrytitle\"\u003eROLLBACK TO SAVEPOINT\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]","synopsis_text":"ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/sql-rollback.html","sha256":"fcabc82dfc3007cefdcc58350ad1c68f62dbdba0ac36e1a71e40114801bb4bc2"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"zh_from":"same-version-pgdoc"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"rollback","SourceDatabase":"center","Version":"18","Locale":"en","Title":"ROLLBACK","Summary":"abort the current transaction","BodyHTML":"\u003cpre\u003eROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eROLLBACK\u003c/code\u003e rolls back the current transaction and causes all the updates made by the transaction to be discarded.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eParameters\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\u003eOptional key words. They have no effect.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eAND CHAIN\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eIf \u003ccode\u003eAND CHAIN\u003c/code\u003e is specified, a new (not aborted) transaction is immediately started with the same transaction characteristics (see \u003ca href=\"/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\" rel=\"nofollow\"\u003e\u003cspan\u003eSET TRANSACTION\u003c/span\u003e\u003c/a\u003e) as the just finished one. Otherwise, no new transaction is started.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eNotes\u003c/h2\u003e\u003cp\u003eUse \u003ca href=\"/docs/18/sql-commit.html\" title=\"COMMIT\" rel=\"nofollow\"\u003e\u003ccode\u003eCOMMIT\u003c/code\u003e\u003c/a\u003e to successfully terminate a transaction.\u003c/p\u003e\u003cp\u003eIssuing \u003ccode\u003eROLLBACK\u003c/code\u003e outside of a transaction block emits a warning and otherwise has no effect. \u003ccode\u003eROLLBACK AND CHAIN\u003c/code\u003e outside of a transaction block is an error.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eExamples\u003c/h2\u003e\u003cp\u003eTo abort all changes:\u003c/p\u003e\u003cpre\u003eROLLBACK;\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eCompatibility\u003c/h2\u003e\u003cp\u003eThe command \u003ccode\u003eROLLBACK\u003c/code\u003e conforms to the SQL standard. The form \u003ccode\u003eROLLBACK TRANSACTION\u003c/code\u003e is a PostgreSQL extension.\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/begin/?v=18\" title=\"BEGIN\" rel=\"nofollow\"\u003e\u003cspan\u003eBEGIN\u003c/span\u003e\u003c/a\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-to-savepoint/?v=18\" title=\"ROLLBACK TO SAVEPOINT\" rel=\"nofollow\"\u003e\u003cspan\u003eROLLBACK TO SAVEPOINT\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"wiki-repair-20261023:93225a29f342291148b6f0f592fe12e5a74edfeb0a9a68495ebb5ac59bed3546","ContentHash":"c9581dc775f5c81c39cadae2d72e12ed0ca7b87c62c012405ef8af5f61c7db59","Payload":{"related":["begin","commit","rollback-to-savepoint"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e rolls back the current transaction and causes all the updates made by the transaction to be discarded.\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\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eAND CHAIN\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eIf \u003ccode class=\"literal\"\u003eAND CHAIN\u003c/code\u003e is specified, a new (not aborted) transaction is immediately started with the same transaction characteristics (see \u003ca href=\"/docs/18/sql-set-transaction.html\" title=\"SET TRANSACTION\"\u003e\u003cspan class=\"refentrytitle\"\u003eSET TRANSACTION\u003c/span\u003e\u003c/a\u003e) as the just finished one. Otherwise, no new transaction is started.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003eUse \u003ca href=\"/docs/18/sql-commit.html\" title=\"COMMIT\"\u003e\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e\u003c/a\u003e to successfully terminate a transaction.\u003c/p\u003e\u003cp\u003eIssuing \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e outside of a transaction block emits a warning and otherwise has no effect. \u003ccode class=\"command\"\u003eROLLBACK AND CHAIN\u003c/code\u003e outside of a transaction block is an error.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eTo abort all changes:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eROLLBACK;\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003eThe command \u003ccode class=\"command\"\u003eROLLBACK\u003c/code\u003e conforms to the SQL standard. The form \u003ccode class=\"literal\"\u003eROLLBACK TRANSACTION\u003c/code\u003e is a PostgreSQL extension.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/begin/?v=18\" title=\"BEGIN\"\u003e\u003cspan class=\"refentrytitle\"\u003eBEGIN\u003c/span\u003e\u003c/a\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-to-savepoint/?v=18\" title=\"ROLLBACK TO SAVEPOINT\"\u003e\u003cspan class=\"refentrytitle\"\u003eROLLBACK TO SAVEPOINT\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","synopsis_html":"ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]","synopsis_text":"ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]"}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","6.4","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}
