Bird
0
0

Identify the error in this SQL transaction block: START TRANSACTION; UPDATE accounts SET balance = balance - 100 WHERE id = 1; COMMIT; ROLLBACK;

medium📝 Debug Q6 of 15
SQL - Transactions and Data Integrity
Identify the error in this SQL transaction block: START TRANSACTION; UPDATE accounts SET balance = balance - 100 WHERE id = 1; COMMIT; ROLLBACK;
AMissing SAVEPOINT before ROLLBACK
BCOMMIT should be after ROLLBACK
CROLLBACK after COMMIT is invalid
DSTART TRANSACTION is incorrect syntax
Step-by-Step Solution
Solution:
  1. Step 1: Understand transaction flow

    COMMIT finalizes changes; after commit, rollback has no effect.
  2. Step 2: Analyze the commands order

    ROLLBACK after COMMIT is invalid because transaction is already closed.
  3. Final Answer:

    ROLLBACK after COMMIT is invalid -> Option C
  4. Quick Check:

    Rollback after commit error = B [OK]
Quick Trick: Rollback cannot follow commit in same transaction [OK]
Common Mistakes:
  • Thinking rollback can undo committed changes
  • Confusing savepoint usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes