Bird
0
0

Consider this sequence with auto-commit OFF:

medium📝 query result Q13 of 15
SQL - Transactions and Data Integrity
Consider this sequence with auto-commit OFF:
INSERT INTO users (id, name) VALUES (1, 'Alice');
ROLLBACK;
SELECT * FROM users WHERE id = 1;

What will the SELECT query return?
AA row with id=1 and name='Alice'
BNo rows
CSyntax error
DAll rows in users table
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the INSERT and ROLLBACK with auto-commit OFF

    With auto-commit OFF, the INSERT is not saved until COMMIT. ROLLBACK undoes the INSERT.
  2. Step 2: Determine SELECT result after rollback

    Since the INSERT was undone, the SELECT finds no row with id=1.
  3. Final Answer:

    No rows -> Option B
  4. Quick Check:

    ROLLBACK undoes changes, so SELECT returns no rows [OK]
Quick Trick: ROLLBACK undoes uncommitted changes, so no new rows appear [OK]
Common Mistakes:
  • Assuming INSERT is saved without COMMIT
  • Thinking ROLLBACK only affects future queries
  • Expecting syntax error from ROLLBACK

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes