AI InterviewSearch…Search problems, topics, or pages…Ctrl KGet started
Mediumdbmsisolationtransactions

~90s

Choosing an isolation level

Which isolation level prevents dirty reads but still permits non-repeatable reads?

Show the answer and the worked solution

Correct answer: B.

Read Committed

Worked solution

  1. Read Uncommitted lets a transaction see rows another transaction has not committed, which is precisely a dirty read.
  2. Read Committed reads only committed rows, so dirty reads disappear; but a row read twice may differ if another transaction commits an update in between, which is a non-repeatable read.
  3. Repeatable Read stops that as well, and Serializable additionally stops phantom rows.

Answer: Read Committed.

The idea

The four levels form a ladder against three anomalies: dirty read, non-repeatable read and phantom. Naming the anomaly the question describes points straight at the level.

Shortcut. The name says it: Read Committed reads only committed data, so no dirty reads, but holds no read locks to the end, so a re-read can change.

Common trap. "Repeatable Read" also prevents dirty reads, but it prevents non-repeatable reads too, which the question says must still be allowed.

Choosing an isolation level — Aptitude Question

Choosing an isolation level: Which isolation level prevents dirty reads but still permits non-repeatable reads? Answer and worked solution on CodeKairo.

Question

Which isolation level prevents dirty reads but still permits non-repeatable reads?

Options

  1. Read Uncommitted
  2. Read Committed
  3. Repeatable Read
  4. Serializable
Show the answer and the worked solution

Correct answer: B. Read Committed

Worked solution

  1. Read Uncommitted lets a transaction see rows another transaction has not committed, which is precisely a dirty read.
  2. Read Committed reads only committed rows, so dirty reads disappear; but a row read twice may differ if another transaction commits an update in between, which is a non-repeatable read.
  3. Repeatable Read stops that as well, and Serializable additionally stops phantom rows.

Answer: Read Committed.

The idea

The four levels form a ladder against three anomalies: dirty read, non-repeatable read and phantom. Naming the anomaly the question describes points straight at the level.

Shortcut. The name says it: Read Committed reads only committed data, so no dirty reads, but holds no read locks to the end, so a re-read can change.

Common trap. "Repeatable Read" also prevents dirty reads, but it prevents non-repeatable reads too, which the question says must still be allowed.

All OS, DBMS & Networks questions · placement mock tests