Isolation levels are defined based on phenomena that must be prevented during the concurrent execution of transactions.
The following phenomena are preventable:
Dirty read: A transaction reads the data that has not been committed by other transactions.
Non-repeatable read: When you query a row of data that you have read, you find that this row of data has been modified or deleted. For example, for
select c2 from test where c1=1;, the value ofc2queried for the first time is1. When you queryc2again, its value becomes2because other transactions have modified the value.Phantom read: A read-only request returns a group of rows that meet query conditions. The next time the request is executed, you find that other rows that meet the conditions have been inserted by a committed transaction.
Based on the preceding three phenomena, the ANSI and ISO/IEC standards define the following isolation levels:
Read uncommitted
Read committed
Repeatable read
Serializable
The following table compares the four isolation levels.
| Isolation level | Dirty read | Non-repeatable read | Phantom read |
|---|---|---|---|
| Read uncommitted | Possible | Possible | Possible |
| Read committed | Impossible | Possible | Possible |
| Repeatable read | Impossible | Impossible | Possible |
| Serializable | Impossible | Impossible | Impossible |
OceanBase Database supports the following isolation levels:
Oracle mode
Read committed
Repeatable read
Serializable
MySQL mode
Read committed
Repeatable read
Serializable
It is similar to the serializable isolation level in Oracle Database, but is not strictly a serializable isolation level.
By default, OceanBase Database uses the read committed isolation level.