DML & Transactions · Question 13 · Medium

DML & Transactions question 13

A session is in autocommit mode (the default in MySQL, PostgreSQL and SQLite) and no transaction has been started. An UPDATE that changes 5 rows runs successfully. The user then issues ROLLBACK. What is the state of the 5 rows?

  1. They return to their old values, because ROLLBACK undoes the last statement
  2. They are deleted from the table
  3. They stay locked until a COMMIT is issued
  4. They keep the updated values, because the UPDATE was committed as soon as it finished
Answer and explanation

Answer: D. They keep the updated values, because the UPDATE was committed as soon as it finished

Explanation: In autocommit mode every statement is its own transaction and is committed automatically when it succeeds. There is no open transaction left for ROLLBACK to undo, so the changes stay.

Previous: Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |… · Next: Table Cart: item | qty Rice | 1 Which items does the SELECT return after these…

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