Interview Question

What is phantom read?

A phantom read changes the row set matching a repeated condition.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

A phantom read occurs when repeating a condition query returns a changed set of rows because another transaction inserted, deleted, or updated matching rows. • The anomaly concerns the set selected by a predicate. • Isolation implementations differ in how they prevent it. • Serializable execution protects broader transaction rules and may require retries.

💡 SQL Example

BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE;

Result

BEGIN

⚡ Quick Revision

A phantom read changes the row set matching a repeated condition.