In the ANSI/SQL Server isolation hierarchy, which is the strictest isolation level that prevents dirty reads, non-repeatable reads, and phantom rows by using key-range locking?

Difficulty: Easy

Correct Answer: SERIALIZABLE.

Explanation:


Introduction / Context:
Different isolation levels trade concurrency for consistency. The strictest level prevents not just dirty and non-repeatable reads but also phantoms.



Given Data / Assumptions:

  • Isolation levels: READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE.
  • Requirement: eliminate dirty reads, non-repeatable reads, and phantom inserts.


Concept / Approach:

SERIALIZABLE enforces serial transaction execution semantics by acquiring key-range locks, which block inserts or deletes in the qualified key ranges during the transaction, thereby preventing phantoms.



Step-by-Step Solution:

1) READ UNCOMMITTED: allows dirty reads → not strictest.2) READ COMMITTED: no dirty reads but allows non-repeatable reads.3) REPEATABLE READ: prevents non-repeatable reads but allows phantoms.4) SERIALIZABLE: prevents dirty, non-repeatable, and phantom reads.


Verification / Alternative check:

Documentation lists SERIALIZABLE as the top level; query hints like HOLDLOCK (equivalent to SERIALIZABLE) show range locking behavior.



Why Other Options Are Wrong:

REPEATABLE READ lacks range locks. READ COMMITTED releases S locks per statement. READ UNCOMMITTED allows dirty reads.



Common Pitfalls:

Confusing REPEATABLE READ with phantom prevention. Assuming SERIALIZABLE always means poor performance; it depends on workload and index design.



Final Answer:

SERIALIZABLE.

More Questions from SQL Server 2000

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion