Database Basics

Among the problems that occur when transactions run concurrently, which correctly describes a dirty read?

  1. AA transaction reads an update that another transaction has not yet committed, and because that transaction then rolls back, it ends up using a value that never existed
  2. BReading the same row twice within one transaction gives a different value, because another transaction updated the row and committed in between
  3. CRunning a search with the same condition twice gives a different number of rows, because another transaction added a row and committed in between
Show answer and explanation

Answer: A. A transaction reads an update that another transaction has not yet committed, and because that transaction then rolls back, it ends up using a value that never existed

A dirty read is the problem of reading uncommitted (not yet permanent) data. If the transaction that made the update later rolls back, the value read is one that was never made permanent, and any processing based on it is wrong. Finding that the same row has a different value when read twice is a non-repeatable read, and finding that rows matching a search condition have increased or decreased is a phantom read. These problems occur when transaction isolation is insufficient, and in SQL you choose how many of them to prevent by setting the isolation level. At isolation levels of READ COMMITTED and above, dirty reads do not occur.

  • A. Correct. Reading an update that has not been committed is a dirty read.
  • B. This describes a non-repeatable read.
  • C. This describes a phantom read.
Practice this topic Back to topic

Related calculators

Books on Database Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Database Basics questions

  1. Transaction T1 ran SELECT COUNT(*) FROM orders WHERE amount >= 1000 and got 8. Immediately afterwards, T2 inserted an order row with an amount of 2000 and committed. When T1 ran the same SELECT statement again, it got 9. What is this phenomenon?
  2. Among the isolation levels defined by the SQL standard, which correctly lists the phenomena that can occur under READ COMMITTED?
  3. Transaction T1 holds a shared lock on a row and is reading it. T2 requests a shared lock and T3 requests an exclusive lock on the same row. Which is correct for the period until T1 releases its lock?
  4. Which correctly describes two-phase locking (2PL), used for concurrency control of transactions?
  5. Transaction T1 took an exclusive lock on row A and then requested a lock on row B, while T2 took an exclusive lock on row B and then requested a lock on row A, so neither can proceed. What does a DBMS typically do when it detects this situation?