Table of Contents

Oracle Database - SAVEPOINT (of a transaction)

About

A savepoint is a user-declared intermediate marker within the context of a transaction. Internally, this marker resolves to an SCN. Savepoints divide a long transaction into smaller parts.

If you use savepoints in a long transaction, then you have the option later of rolling back work performed before the current point in the transaction but after a declared savepoint within the transaction. Thus, if you make an error, you do not need to resubmit every statement.

Savepoint naming convention: Oracle Database - Naming convention

A rollback to a savepoint in an uncommitted transaction means undoing any changes made after the specified savepoint, but it does not mean a rollback of the transaction itself.

When a transaction is rolled back to a savepoint when a “ROLLBACK TO SAVEPOINT” is performed, the following occurs:

The transaction remains active and can be continued.

Management

Creation

savepoint name;

A new savepoint with the same name will overwrite the old one.

Delete

All existing savepoint are deleted with a commit

Example

update employees set age = 42 where emp_name = "gerard";
savepoint sp1;
update employees set firstname = "nico" where emp_name = "gerard";
rollback work to sp1;
commit;

Documentation / Reference