DML & Transactions · Question 14 · Medium

Table Cart: item | qty Rice | 1 Which items does the SELECT return after these statements?

BEGIN;
SAVEPOINT s1;
INSERT INTO Cart VALUES ('Dal', 2);
ROLLBACK TO SAVEPOINT s1;
INSERT INTO Cart VALUES ('Atta', 1);
COMMIT;
SELECT item FROM Cart ORDER BY item;
  1. Rice
  2. Atta; Dal; Rice
  3. Atta; Rice
  4. Atta
Answer and explanation

Answer: C. Atta; Rice

Explanation: ROLLBACK TO SAVEPOINT undoes only the work done after the savepoint, which is the Dal insert. Rice was already in the table, and Atta is inserted afterwards and committed.

Previous: A session is in autocommit mode (the default in MySQL, PostgreSQL and SQLite)… · Next: Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…

Practise dml & transactions

Try a fresh set of dml & transactions questions with an explanation after every answer, free and without signing up: DML & Transactions practice. Or sit a full placement mock test.

More dml & transactions questions

More sql practice

SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge