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 set several savepoints.
obclient [SYS]> SET session autocommit=off;
Query OK, 0 rows affected
obclient [SYS]> BEGIN;
Query OK, 0 rows affected
obclient [SYS]> INSERT INTO ordr(id, name) VALUES(6,'FR');
Query OK, 1 row affected
obclient [SYS]> SAVEPOINT fr;
Query OK, 0 rows affected
obclient [SYS]> INSERT INTO ordr(id, name) VALUES(7,'RU');
Query OK, 1 row affected
obclient [SYS]> SAVEPOINT ru;
Query OK, 0 rows affected
obclient [SYS]> INSERT INTO ordr(id, name) VALUES(8,'CA');
Query OK, 1 row affected
obclient [SYS]> SAVEPOINT ca;
Query OK, 0 rows affected