gpt4 book ai didi

sql-server-2008-r2 - 在 SQL Server 2008 R2 中的另一个 SNAPSHOT 事务中写入 SNAPSHOT 隔离级别 block 写入

转载 作者:行者123 更新时间:2023-12-04 11:41:12 28 4
gpt4 key购买 nike

对于 SQL Server 2008 R2 中的 SNAPSHOt 隔离级别,MSDN ADO.Net 文档中提到了以下内容:

Transactions that modify data do not block transactions that read data, and transactions that read data do not block transactions that write data, as they normally would under the default READ COMMITTED isolation level in SQL Server.



当两个事务都处于 SNAPSHOT 隔离模式时,没有提到写入是否会阻止写入。所以我的问题如下:
SNAPSHOT 事务 1 块中的写入是否会写入另一个 SNAPSHOT 事务 2 中的相同表?

最新更新

在对我的问题进行了大量思考之后,我得出了如下段落所述的结论。希望其他人可以对此有所了解。

There is no relational database in which writes do NOT block writes. In other words, writes will always block writes. Writes would include statements like INSERT or UPDATE or DELETE. This is true no matter which isolation level you use, since all relational databases need to implement data consistency, when multiple writes are happening in database. Of course, the simultaneous writes need to be conflicting ( as in inserting into the same table or updating the same row/s) for this blocking to occur.

最佳答案

Ligos 实际上是不正确的——如果两个单独的事务试图在 Snapshot 打开的情况下更新相同的记录,事务 2 将被阻塞,直到事务 1 释放锁。然后,并且只有在那时,您才会收到错误 3960。我意识到这个线程已经超过 2 年了,但我想避免出现错误信息。

甚至 Ligos 引用的链接也说明了我在上面提到的完全相同的内容(请查看最后一个非红色段落)

如果尝试更新的两条记录(即行)不同,则写入与写入不会被阻止

关于sql-server-2008-r2 - 在 SQL Server 2008 R2 中的另一个 SNAPSHOT 事务中写入 SNAPSHOT 隔离级别 block 写入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12684477/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com