Bird
0
0

What is the result of this SQL sequence?

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

    ROLLBACK undoes all changes made in the current transaction.
  2. Step 2: Analyze the SELECT after rollback

    The inserted row is removed, so SELECT returns no rows with id 1.
  3. Final Answer:

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

    ROLLBACK removes changes made in transaction [OK]
Quick Trick: ROLLBACK cancels all changes in the transaction [OK]
Common Mistakes:
  • Expecting inserted rows to remain after rollback
  • Confusing rollback with commit

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes