网上关于这部分的介绍很多,这里写下自己对这几个隔离级别的理解。
首先解释下什么是隔离性(isolation):DB中的隔离性指的是一个操作产生的影响什么时候以哪种方式可以对其他并发操作可见。
然后再介绍几个容易混淆的概念:幻读,脏读和不可重复读
脏读(dirty reads)
某一个事务读取了另一个事务中已经修改了的但是尚未commit的数据,这就是脏读。一旦另一个事务发生回滚,则读取的值就是脏读了。
幻读(phantom 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.
在一个事务中,两个同样的查询语句得到的查询结果却不一样,这就是幻读,这里要注意一点:幻读是针对多条返回结果而言的。
不可重复读(non-repeatable read)
A[……]