回滚

回滚 •结束当前事务并撤消当前事务中完成的任何DML和DDL语句的效果。

句法

回滚 [ WORK ]

ROLLBACK TO SAVEPOINT savepoint_name

描述

Stops and ends the current transaction. Use the 回滚 statement to stop a transaction and undo work done in the current transaction, or undo the work done after a specified savepoint. Execution of 回滚 discards any DML updates made by the transaction being stopped.
回滚 没有参数释放事务中的所有名为SavePoints。
If autocommit is off or if you specified 开始交易 (see 开始交易), specify 犯罪 (see 犯罪)提交在交易中完成的工作并结束交易。

NuoDB recommends that you explicitly end transactions in application programs using either a 犯罪 or 回滚 statement. If you do not explicitly commit the transaction and the program terminates abnormally then NuoDB will rollback the current uncommitted transaction.

要回滚您当前的交易,无需特权。

保存 有关保存点的更多信息。

参数

WORK

This keyword is ignored. 回滚 WORK is the same as just 回滚.

savepoint_name

Name of 保存 that you want to be able to specify with 回滚 TO SAVEPOINT. Only those changes made after the savepoint are undone.

例子

示例1:在执行时提交每个语句,因此不可能回滚。
表演 AUTOCOMMIT
    Autocommit is on
CREATE TABLE t1 (f1 int);
 INTO t1 VALUES (1);
选择 * FROM t1;
 F1
 ---
  1

回滚;   /* ROLLBACK does nothing because the work is already committed. */
选择 * FROM t1;
 F1
 ---
  1
示例2:自动车处已关闭,工作可以回滚。

此示例使用第一个示例中创建的表。

表演 AUTOCOMMIT
    Autocommit is off

 INTO t1 VALUES (2);
选择 * FROM t1;
 N
 --
 1
 2

回滚;
选择 * FROM t1;
 N
 --
 1