Practice mode DBMS and SQL

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.