隔离级别与脏读幻读
数据库操作 issue
- 更新丢失(lost update):当系统允许两个事务同时更新同一数据时,发生更新丢失
- 脏读(dirty read):当一个事务读取另一个事务尚未提交的修改时,产生脏读。
- 非重复读(nonrepeatable read):同一查询在同一事务中多次进行,由于其他提交事务所做的修改或删除,每次返回不同的结果集,此时发生非重复读。(A transaction rereads data it has previously read and finds that another committed transaction has modified or deleted the data. )
- 幻像(phantom read):同一查询在同一事务中多次进行,由于其他提交事务所做的插入操作,每次返回不同的结果集,此时发生幻像读。(A transaction reexecutes a query returning a set of rows that satisfies a search condition and finds that another committed transaction has inserted additional rows that satisfy the condition. )
ANSI/ISO SQL92标准定义的隔离级别:
- 未提交读(read uncommitted)
- 提交读(read committed)这是大多是数据库的默认隔离级别并被大多vendors支持
- 重复读(repeatable read) –行级锁定,不能写该行
- 序列化(serializable) –表锁定,不能插入新的数据
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 石头记!
评论