SQL Server Interview Question #248

What is a phantom read?

Advanced Transactions & Concurrency Senior Advanced

Detailed Explanation

A phantom read occurs when a transaction executes a predicate query, another transaction inserts or deletes rows that satisfy that predicate, and a repeated query returns a different set of rows.

REPEATABLE READ protects rows already read but does not generally protect the entire qualifying key range from new matching rows. SERIALIZABLE uses key-range protection to prevent this type of phantom within the protected transaction.

SNAPSHOT isolation provides a different consistency model using row versions.