Open topic with navigation
ROLLBACK — end the current transaction and undo the effect of any DML and DDL statements that was done in the current transaction.
ROLLBACK [ WORK ] ROLLBACK TO SAVEPOINT
Stops and ends the current transaction. Use the
ROLLBACK statement to stop a transaction and undo work done in the current transaction, or undo the work done after a specified savepoint. Execution of
ROLLBACK discards any DML updates made by the transaction being stopped.
ROLLBACK with no arguments releases all named savepoints within the transaction.
If autocommit is off or if you specified
START TRANSACTION (see
START TRANSACTION), specify
COMMIT) to commit the work done in the transaction and end the transaction.
NuoDB recommends that you explicitly end transactions in application programs using either a
ROLLBACK statement. If you do not explicitly commit the transaction and the program terminates abnormally then NuoDB will rollback the current uncommitted transaction.
To roll back your current transaction, no privileges are necessary.
SAVEPOINT for more information about savepoints.
This keyword is ignored.
ROLLBACK WORK is the same as just
SAVEPOINT that you want to be able to specify with
ROLLBACK TO SAVEPOINT. Only those changes made after the savepoint are undone.
SHOW AUTOCOMMITAutocommit is on
CREATE TABLE t1 (f1 int); INSERT INTO t1 VALUES (1); SELECT * FROM t1;F1 --- 1
ROLLBACK;/* ROLLBACK does nothing because the work is already committed. */
SELECT * FROM t1;F1 --- 1
This example uses table created in the first example.
SHOW AUTOCOMMITAutocommit is off
INSERT INTO t1 VALUES (2); SELECT * FROM t1;N -- 1 2
ROLLBACK; SELECT * FROM t1;N -- 1