You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SQL Server中Read Uncommitted与Read Committed隔离级执行逻辑问询

事务隔离级别与并发执行逻辑分析

Employees表初始数据:

idnamesalary
1Stanley500
2Jan600
3Zaid700

事务定义

T1(隔离级别:Read Uncommitted)

Begin Transaction
S1: update Employees set salary = 2*salary where name = 'Zaid'
S2: update Employees set salary = 3*salary where name = 'Zaid'
Commit;

T2(隔离级别:Read Committed)

Begin Transaction
S3: update Employees set salary = salary - 20 where name = 'Zaid'
S4: update Employees set salary = salary - 10 where name = 'Zaid'
Commit;

初步执行时间线假设(@value代表Zaid初始薪资700)

TimeTransaction 1Transaction 2Salary(当前时间的薪资值)
0Begin Transaction@value
1S1Begin Transaction2 * @value
2S3@value - 20
3S23*(2*@value -20)
4S4(@value - 20) - 10
5Commit;3*(2*@value -20)【此处存疑】
6Commit;(@value - 20) - 10 ?

核心疑问

  • 已知Read Uncommitted允许T1读取T2未提交的变更,Read Committed仅允许T2读取其他事务已提交的变更,但二者并发交互时的具体执行逻辑是什么?上述时间线是否准确?
  • 若T2先启动,T1会等待T2提交,还是忽略T2的排他锁并设置自己的锁?是否会按如下时间线执行?

READ UNCOMMITTED是限制最低的隔离级别,因为它会忽略其他事务设置的锁。该级别下的事务可以读取其他事务未提交的修改数据,即“脏读”。

另一种时间线假设

TimeTransaction 1Transaction 2
0Begin Transaction
1Begin TransactionS3
2S1
3S2
4Commit;
5S4
6Commit;

内容的提问来源于stack exchange,提问作者BrainlessPOMO

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 15:25:44