Bird
0
0

Given the SQL commands:

medium📝 query result Q4 of 15
SQL - Transactions and Data Integrity
Given the SQL commands:
BEGIN TRANSACTION;
DELETE FROM customers WHERE id = 3;
ROLLBACK;
SELECT * FROM customers WHERE id = 3;

What will the SELECT query return?
AThe row with id = 3 will still be present.
BNo rows will be returned because the delete was committed.
CAn error will occur because of the rollback.
DThe row will be partially deleted.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze DELETE and ROLLBACK

    The DELETE removes the row but ROLLBACK cancels this change.
  2. Step 2: Effect on SELECT

    Since the deletion was rolled back, the row remains in the table.
  3. Final Answer:

    The row with id = 3 will still be present. -> Option A
  4. Quick Check:

    ROLLBACK restores deleted rows [OK]
Quick Trick: ROLLBACK undoes deletes before commit [OK]
Common Mistakes:
  • Assuming rollback deletes data permanently
  • Thinking rollback causes errors
  • Believing partial deletes occur

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes