Jump to Navigation

050 - MySQL Rollback to Savepoint

ROLLBACK TO SAVEPOINT identifier

This statement instructs the server to reverse SQL statements for the current transaction back to a point
marked in the transaction by the SAVEPOINT statement. Any transactions for the session made after the
savepoint are undone. This is in contrast to ROLLBACK by itself, which undoes all changes since the start
of the transaction. Transaction statements are currently supported by the InnoDB, NDB Cluster, and BDB
storage engines and are ignored if used with MyISAM tables. Multiple savepoint may be set up during
a transaction.

Example:

START TRANSACTION;

LOCK TABLE orders WRITE;

INSERT DATA INFILE '/tmp/customer_info.sql'
INTO TABLE order;

SAVEPOINT order_import;

INSERT DATA INFILE '/tmp/customer_orders.sql'
INTO TABLE order;

SELECT...

SAVEPOINT orders_import1;

INSERT DATA INFILE '/tmp/customer_orders1.sql'
INTO TABLE order;

SELECT...

ROLLBACK TO SAVEPOINT orders_imports;

 

 

MySQL:


Main menu 2

Story | by Dr. Radut