The SAVEPOINT statement marks a savepoint during a transaction. You can roll back a transaction to a savepoint. Savepoints are optional. A transaction can have multiple savepoints.
Mark a savepoint
After a transaction is started, you can use the following statement to mark a savepoint:
SAVEPOINT pointname;
pointname specifies the name of the transaction savepoint.
Example: Start a transaction and mark multiple savepoints.
obclient [test]> SET SESSION autocommit=0;
Query OK, 0 rows affected
obclient [test]> BEGIN;
Query OK, 0 rows affected
obclient [test]> INSERT INTO ordr(id, name) VALUES(6,'FR');
Query OK, 1 row affected
obclient [test]> SAVEPOINT fr;
Query OK, 0 rows affected
obclient [test]> INSERT INTO ordr(id, name) VALUES(7,'RU');
Query OK, 1 row affected
obclient [test]> SAVEPOINT ru;
Query OK, 0 rows affected
obclient [test]> INSERT INTO ordr(id, name) VALUES(8,'CA');
Query OK, 1 row affected
obclient [test]> SAVEPOINT ca;
Query OK, 0 rows affected