SAVEPOINT (SQLite)
SAVEPOINT (SQLite) is a SQL statement in the SQLite Specific category. SQLite: nested transaction support via savepoints. Unlike BEGIN/COMMIT, savepoints can be nested. The syntax is SAVEPOINT sp_name; RELEASE SAVEPOINT sp_name; ROLLBACK TO SAVEPOINT sp_name;. It returns nested savepoint. A typical example: SAVEPOINT sp1; INSERT INTO log VALUES ('Step 1'); SAVEPOINT sp2; INSERT INTO log VALUES ('Step 2'); ROLLBACK TO SAVEPOINT sp2; -- Undo Step 2 only RELEASE SAVEPOINT sp1; -- Save Step 1 -- Note: SQLite only supports one level of BEGIN/COMMIT -- Savepoints provide nested transaction behavior A close relative is AUTOINCREMENT (SQLite), which sQLite: unlike AUTO_INCREMENT in MySQL, only INTEGER PRIMARY KEY columns auto-increment. AUTOINCREMENT guarantees unique increasing IDs. A close relative is ROWID / _ROWID_, which sQLite: every row has an implicit 64-bit ROWID. INTEGER PRIMARY KEY becomes an alias for ROWID. A close relative is ATTACH DATABASE, which sQLite: connects another database file to the current connection, allowing cross-database queries.