DBMS Interview Questions · Question 15

What is a dirty read, and which isolation level allows it?

Interview preparation resource from Gate Smashers.

Interview-ready answer

A dirty read occurs when one transaction reads a value written by another transaction before that second transaction has committed. The READ UNCOMMITTED isolation level allows dirty reads. Example: T1 updates a balance from 400 to 500 but has not committed; T2 reads 500 while T1 is still active; if T1 later rolls back to 400, T2 has used a value that never became permanent (dirty data). READ COMMITTED and stronger isolation levels prevent dirty reads by ensuring a transaction does not read another transaction's uncommitted changes.

Understand it clearly

Definition

A dirty read happens when one transaction reads a value written by another transaction that has not yet committed. The read value may be rolled back later, so it is not guaranteed to be permanent or correct.

Isolation level that allows it

READ UNCOMMITTED is the standard isolation level that can allow dirty reads. Under this level a transaction may observe changes made by other transactions before those changes are committed.

Concrete example (two transactions)

This sequence shows how a dirty read can occur:

  • Step 1: T1: Update balance = 500 (original was 400) — not committed yet.
  • Step 2: T2: Read balance = 500 (reads T1's uncommitted change).
  • Step 3: T1: ROLLBACK — database value returns to 400; T2 used a value (500) that never became permanent.

Prevention

READ COMMITTED and stronger standard isolation levels prevent dirty reads by ensuring a transaction does not read another transaction's uncommitted changes.

Quick comparison
BasisREAD UNCOMMITTEDREAD COMMITTED and stronger
Dirty reads allowed?Yes — can read another transaction's uncommitted changes.No — prevents reading uncommitted changes.