阅读这两个潜在的和未提交的事务数据这两个、事务、数据

2023-09-06 22:50:39 作者:碧月羞

使用从.NET的SQL Server,它是可能的(使用相同或不同的连接)来阅读这两个基础数据还有的尚未提交的从另一个单独的连接的变化?

Using SQL Server from .NET, is it possible (using the same or separate connections) to read both the underlying data as well as the as-yet uncommitted changes from another separate connection?

例如:

我有连接1,这将启动一个事务,并插入与标识== 1的记录到一个表,但不承诺它

I have Connection1, which starts a transaction and inserts a record with Id == 1 into a table but doesn't commit it

从连接2,我想读表不存在该行

From Connection2, I would like to read the table without that row existing

从连接2或连接3,我想读表与行现有的。

From Connection2 or Connection3, I would like to read the table with the row existing.

推荐答案

是的,你需要启用脏读又称读取未提交

Yes, you need to enable dirty reads aka READ UNCOMMITTED

编辑:

要读这两组数据,你会在一个连接中需要的快照隔离的组合,而在另一个读取未提交。

To read both sets of data you'd need a combination of "snapshot isolation" in one connection and "read uncommitted" in another.

情况因人而异。这是不是...

YMMV. It isn't something...

在我试过 见一个用 在我有信心