What Is Isolation in a Database?

Isolation controls how and when changes are made in a database

Isolation is an integral part of database transactional properties. It is the third property of ACID (Atomicity, Consistency, Isolation, Durability) and these properties ensure that data is consistent and accurate. 

Isolation is the database-level property that controls how and when changes are made and if they become visible to each other. One of the goals of isolation is to allow multiple transactions occurring at the same time without impacting each other’s execution.

How Isolation Works

For example, if Joe issues a transaction against a database at the same time that Mary issues a different transaction, both transactions should operate on the database in an isolated manner. The database should either perform Joe’s entire transaction before executing Mary’s or vice-versa. This prevents Joe’s transaction from reading intermediate data produced as a side effect of part of Mary’s transaction that will not eventually be committed to the database. Note that the isolation property does not ensure which transaction will execute first, merely that they will not interfere with each other.

Isolation Levels

There are four levels of isolation:

  1. Serializable is the highest level, which means that the transactions will be completed before another transaction is able to start.
  2. Repeatable reads allow transactions to be accessed once the transaction has started, even though it hasn’t been finished.
  1. Read committed allows the data to be accessed after the data has been committed to the database, but not before then.
  2. Read uncommitted is the lowest level of isolation and allows data to be accessed before the changes have been made.