Difficulty: Easy
Correct Answer: Correct
Explanation:
Introduction / Context:
Transaction isolation controls visibility and concurrency behavior. SQL Server supports READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SNAPSHOT, and SERIALIZABLE. Choosing a level affects blocking, deadlocks, and data correctness.
Given Data / Assumptions:
Concept / Approach:
SERIALIZABLE prevents dirty reads, nonrepeatable reads, and phantom reads by effectively serializing concurrent transactions in conflicting ranges. It uses range locks to stop phantoms. SNAPSHOT avoids many conflicts via versioning, but it does not equate to stricter locking semantics than SERIALIZABLE.
Step-by-Step Solution:
Set isolation level: SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;Run concurrent range queries and inserts; observes blocking due to range locks.Contrast with SNAPSHOT: SET ALLOW_SNAPSHOT_ISOLATION ON; SNAPSHOT readers do not block writers but allow more concurrency via versions.
Verification / Alternative check:
Review phenomena allowed: only SERIALIZABLE disallows dirty, nonrepeatable, and phantom reads under locking semantics.
Why Other Options Are Wrong:
“Snapshot is stricter” is incorrect; it is different, not stricter, and does not use range locks. Repeatable Read does not prevent phantoms.
Common Pitfalls:
Assuming SNAPSHOT equals SERIALIZABLE; ignoring potential blocking overhead at SERIALIZABLE.
Final Answer:
Correct
Discussion & Comments