Database Basics
Among the isolation levels defined by the SQL standard, which correctly lists the phenomena that can occur under READ COMMITTED?
- ANone of dirty reads, non-repeatable reads or phantom reads can occur
- BDirty reads cannot occur, but non-repeatable reads and phantom reads can
- CDirty reads and non-repeatable reads cannot occur, but phantom reads can
Show answer and explanation
Answer: B. Dirty reads cannot occur, but non-repeatable reads and phantom reads can
The SQL standard defines four isolation levels, in order of how few phenomena they prevent: READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ and SERIALIZABLE. Under READ UNCOMMITTED, all three phenomena can occur. READ COMMITTED reads only committed data and so prevents dirty reads, but because each read sees the committed value at that moment, non-repeatable reads and phantom reads can occur. REPEATABLE READ additionally prevents non-repeatable reads, but phantom reads can still occur. SERIALIZABLE prevents all three and guarantees the same result as executing the transactions one at a time in some order. The higher the isolation level, the more lock waits and retries there are and the less work can be processed concurrently, so the level is chosen to suit the application. In real DBMSs, the default isolation level, and the phenomena each level actually prevents, may be stronger than the standard's minimum requirements.
- A. The level at which none of the three occurs is SERIALIZABLE.
- B. Correct. READ COMMITTED prevents only dirty reads.
- C. This describes REPEATABLE READ.