Bird
0
0

Given auto-commit is OFF, what is the output after these commands?

medium📝 query result Q4 of 15
SQL - Transactions and Data Integrity
Given auto-commit is OFF, what is the output after these commands?
INSERT INTO products (id, name) VALUES (1, 'Pen');
ROLLBACK;
SELECT COUNT(*) FROM products;

Assuming products table was empty before.
ANULL
B1
C0
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand effect of ROLLBACK with auto-commit OFF

    Since auto-commit is OFF, the INSERT is not saved until COMMIT. ROLLBACK undoes the insert.
  2. Step 2: Check final count in products table

    Because the insert was rolled back, the table remains empty, so COUNT(*) returns 0.
  3. Final Answer:

    0 -> Option C
  4. Quick Check:

    ROLLBACK undoes changes with auto-commit OFF [OK]
Quick Trick: ROLLBACK cancels uncommitted changes when auto-commit is OFF [OK]
Common Mistakes:
  • Assuming insert stays after ROLLBACK
  • Confusing auto-commit ON and OFF effects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes