What is Save-Points in SQLite !!!

SQLite also support save-point.

Savepoints allow you to mark specific points in the transaction. You can then accept or rollback to individual save-points without having to commit or rollback an entire transaction. Unlike transactions, you can have more than one save-point active at the same time.

Save-points are sometime called nested transaction.

You can create a save-point with the SAVEPOINT command.

Command : SAVEPOINT savepoint_name

Save-points act as a stack. Whenever you create a new one, it is put at the top of the stack. Save-point identifiers do not need to be unique. If the same save-point identifier is used more than once, the one nearest to the top of the stack is used.

To release a save-point and accept all of the proposed changes made since the savepoint was set, use the

RELEASE command:

RELEASE [SAVEPOINT] savepoint_name

To cancel a set of commands and undo everything back to where a save-point was set, use the ROLLBACK TO command:
ROLLBACK [TRANSACTION] TO [SAVEPOINT] savepoint_name


Discover more from CODE t!ps

Subscribe to get the latest posts sent to your email.

Scroll to Top

Discover more from CODE t!ps

Subscribe now to keep reading and get access to the full archive.

Continue reading