Transaction isolation levels: which level allows dirty reads, nonrepeatable reads, and phantom reads?
-
ARead committed
-
BRead uncommitted
-
CRepeatable read
-
DSerializable
Answer
Correct Answer: Read uncommitted
Explanation
Introduction / Context:Isolation levels regulate what anomalies are possible when transactions run concurrently. The question asks which level is the least strict, permitting all three classic anomalies.
Given Data / Assumptions:
- Dirty read: reading uncommitted changes.
- Nonrepeatable read: same row returns different values within a transaction.
- Phantom read: a re-run of a range query returns a different set of rows.
Concept / Approach:Read uncommitted is the lowest isolation level. It allows dirty reads and therefore also permits nonrepeatable and phantom reads. Higher levels restrict these anomalies progressively.
Step-by-Step Solution:
Map anomalies to levels: Read uncommitted allows all.Read committed blocks dirty reads but not the others.Repeatable read blocks dirty and nonrepeatable, but not phantoms.Serializable blocks all three.Verification / Alternative check:Standards and vendor docs concur on the anomaly allowances described above, with some engine-specific nuances.
Why Other Options Are Wrong:Read committed, Repeatable read, and Serializable progressively restrict anomalies; none of them allow all three.
Common Pitfalls:Confusing “read committed” with “repeatable read”; the latter also prevents nonrepeatable reads, not just dirty reads.
Final Answer:Read uncommitted