java事务不可重复读_脏读、幻读、不可重复读指什么?

sql 1992 标准

2) P2 ("Non-repeatable read"): SQL-transaction T1 reads a row. SQL-

transaction T2 then modifies or deletes that row and performs

a COMMIT. If T1 then attempts to reread the row, it may receive

the modified value or discover that the row has been deleted.

3) P3 ("Phantom"): SQL-transaction T1 reads the set of rows N

that satisfy some. SQL-transaction T2 then

executes SQL-statements that generate one or more rows that

satisfy theused by SQL-transaction T1. If

SQL-transaction T1 then repeats the initial read with the same

, it obtains a different collection of rows.

不可重复读:事务 T1 读到某行;事务 T2 修改或删除这行,提交事务;T1 重新读取发现这行数据已经被修改或删除。

幻读:事务 T1 读取了 N 行;事务 T2 在事务 T1 读取的条件范围内生成了一行或多行数据;T1 重新读取获得与之前不同集合的行数据。

mysql 官网的术语解释,8.0 最新版

non-repeatable read

The situation when a query retrieves data, and a later query within the same transaction retrieves what should be the same data, but the queries return different results (changed by another transaction committing in the meantime).

phantom

A row that appears in the result set of a query, but not in the result set of an earlier query. For example, if a query is run twice within a transaction, and in the meantime, another transaction commits after inserting a new row or updating a row so that it matches the WHERE clause of the query.

This occurrence is known as a phantom read. It is harder to guard against than a non-repeatable read, because locking all the rows from the first query result set does not prevent the changes that cause the phantom to appear.

不可重复读:一个事务内,两次相同条件的查询返回了不同的结果。

幻读:同一个事务中,一条数据出现在这次查询的结果集里,却没有出现在之前的查询结果集中。例如,在一个事务中进行了同一个查询运行了两次,期间被另外一个事务提交插入一行或修改查询条件匹配的一行。它比不可重复读更难防范,因为锁定第一个查询结果集的所有行并不能阻止导致幻象出现的更改。

从以上两处的定义可以看出

影响因素

sql 1992 标准

mysql 术语解释

不可重复读

其他事务修改或删除

未明确不同结果的原因

幻读

新增一行或多行

新增或修改

不同出处的规定存在细微差别,并非完全统一。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值