The SAVEPOINT
command creates a save-point marker
in the transaction log. If there is no active transaction in
progress, the save-point will be marked and an implicit BEGIN DEFERRED TRANSACTION
will
be issued.
Save-points allow subsections of a transaction to be rewound and partially rolled back without losing the entire transaction state. A transaction can have multiple active save-points. Conceptually, these save-points act as if they were on a stack. Save-point names do not need to be unique.
Save-points are useful in multistep processes where each step needs to be attempted and verified before proceeding to the next step. By creating save-points before starting each step, it may be possible to revert just a single step, rather than the whole transaction, when a logical error case is encountered.