in-between state
)Atomicity
(原子性)、Consistency
(一致性)、Isolation
(隔离性)、Durability
(持久性)的首字母缩写,是数据库支持事务所必须遵守的4个特性A non-repeatable read occurs, when during the course of a transaction, a row is retrieved twice and the values within the row differ between reads.
A phantom read occurs when, in the course of a transaction, two identical queries are executed, and the collection of rows returned by the second query is different from the first.
并发事务引发的脏读、不可重复度、幻影读三大问题,严重性排序如下:
脏读 > 不可重复读 > 幻读
需要采取一定的隔离措施,来避免这些问题的出现
SQL标准中提出了四种隔离级别,隔离级别越高,隔离效果越好,事务的执行性能越低
读未提交(read uncommitted) > 读已提交(read committed) > 可重复读(repeatable read) > 串行化(serializable )
读未提交:
读已提交:
可重复读:
串行化:
在并发事务下,这些隔离级别能解决(√
)或仍然存在(X
)的问题,总结如下:
隔离级别 | 脏读 | 不可重复读 | 幻读 |
---|---|---|---|
读未提交 | X | X | X |
读已提交 | √ | X | X |
可重复读 | √ | √ | X |
串行化 | √ | √ | √ |