Table Acc(id) has 2 rows. The following runs: BEGIN; INSERT INTO Acc VALUES (3); SAVEPOINT s1; INSERT INTO Acc VALUES (4); ROLLBACK TO SAVEPOINT s1; COMMIT; How many rows does Acc now contain?
Correct answer D. 3
Explanation
ROLLBACK TO SAVEPOINT undoes only the work done after the savepoint, here the insert of row 4, and the transaction stays open. The insert of row 3 came before s1, so it survives and is made permanent by COMMIT, leaving 3 rows. The answer 2 confuses it with a full ROLLBACK, which would discard everything since BEGIN.
Answer checked How we write and check questions
Discussion