Bird
0
0

What is the result of this transaction sequence?

medium📝 query result Q5 of 15
SQL - Transactions and Data Integrity
What is the result of this transaction sequence?
BEGIN TRANSACTION;
INSERT INTO orders (id, amount) VALUES (1, 50);
ROLLBACK;
SELECT * FROM orders WHERE id = 1;
AOne row with id 1 and amount 50 is returned
BNo rows returned because the insert was rolled back
CSyntax error due to missing COMMIT
DEmpty table error occurs
Step-by-Step Solution
Solution:
  1. Step 1: Understand ROLLBACK effect

    ROLLBACK cancels all changes made in the transaction, undoing the insert.
  2. Step 2: Check SELECT result after rollback

    The inserted row does not exist after rollback, so SELECT returns no rows.
  3. Final Answer:

    No rows returned because the insert was rolled back -> Option B
  4. Quick Check:

    ROLLBACK cancels changes = A [OK]
Quick Trick: ROLLBACK undoes all changes in the transaction [OK]
Common Mistakes:
  • Thinking rollback commits changes
  • Assuming missing COMMIT causes syntax error
  • Expecting errors on SELECT after rollback

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes