Bird
0
0

Given these two transactions:

medium📝 query result Q4 of 15
SQL - Transactions and Data Integrity
Given these two transactions:
Transaction A: LOCK Table X; LOCK Table Y;
Transaction B: LOCK Table Y; LOCK Table X;
What problem can arise when both run simultaneously?
AData inconsistency due to lost updates
BNo conflict, transactions will execute sequentially
CDeadlock due to cyclic locking dependencies
DAutomatic rollback of both transactions without delay
Step-by-Step Solution
Solution:
  1. Step 1: Identify locking order

    Transaction A locks Table X then Y; Transaction B locks Table Y then X.
  2. Step 2: Analyze concurrency

    If both start simultaneously, each may hold one lock and wait for the other, causing deadlock.
  3. Final Answer:

    Deadlock due to cyclic locking dependencies -> Option C
  4. Quick Check:

    Opposite lock order causes deadlock [OK]
Quick Trick: Opposite lock order causes deadlock [OK]
Common Mistakes:
  • Assuming transactions will queue automatically
  • Confusing deadlock with data inconsistency
  • Believing rollback happens immediately without detection

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes