Postgresql 中文操作指南

ROLLBACK

ROLLBACK — 放弃当前事务

ROLLBACK — abort the current transaction

Synopsis

ROLLBACK [ WORK | TRANSACTION ] [ AND [ NO ] CHAIN ]

Description

ROLLBACK 回滚当前事务并导致该事务所做的所有更新被丢弃。

ROLLBACK rolls back the current transaction and causes all the updates made by the transaction to be discarded.

Parameters

  • WORK__TRANSACTION #

    • Optional key words. They have no effect.

  • AND CHAIN #

    • If AND CHAIN is specified, a new (not aborted) transaction is immediately started with the same transaction characteristics (see SET TRANSACTION) as the just finished one. Otherwise, no new transaction is started.

Notes

使用 COMMIT 成功结束一个事务。

Use COMMIT to successfully terminate a transaction.

在事务代码块外部发出 ROLLBACK 会产生一个警告,并不会产生其他效果。 ROLLBACK AND CHAIN 在事务代码块外部会产生一个错误。

Issuing ROLLBACK outside of a transaction block emits a warning and otherwise has no effect. ROLLBACK AND CHAIN outside of a transaction block is an error.

Examples

中止所有更改:

To abort all changes:

ROLLBACK;

Compatibility

命令 ROLLBACK 符合 SQL 标准。表单 ROLLBACK TRANSACTION 是 PostgreSQL 扩展。

The command ROLLBACK conforms to the SQL standard. The form ROLLBACK TRANSACTION is a PostgreSQL extension.