Bird
0
0

You run this SQL code:

medium📝 Debug Q14 of 15
SQL - Transactions and Data Integrity
You run this SQL code:
BEGIN TRANSACTION;
UPDATE accounts SET balance = balance - 100 WHERE id = 5;
COMMIT;
ROLLBACK;

What is the effect of the final ROLLBACK?
AIt undoes the UPDATE and restores the original balance.
BIt causes a syntax error because ROLLBACK cannot follow COMMIT.
CIt has no effect because changes were already committed.
DIt commits the changes again.
Step-by-Step Solution
Solution:
  1. Step 1: Understand COMMIT effect

    COMMIT saves all changes permanently, so the UPDATE is finalized.
  2. Step 2: Analyze ROLLBACK after COMMIT

    ROLLBACK after COMMIT does nothing because there is no active transaction to undo.
  3. Final Answer:

    It has no effect because changes were already committed. -> Option C
  4. Quick Check:

    ROLLBACK after COMMIT = no effect [OK]
Quick Trick: ROLLBACK only undoes uncommitted changes [OK]
Common Mistakes:
  • Thinking ROLLBACK undoes committed changes
  • Assuming ROLLBACK causes error after COMMIT
  • Confusing order of commands

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes