事务中所做的插入在事务被引用之前是否被SELECT可见

时间:2023-01-27 23:39:41

I need a confirmation.

我需要一个确认。

Client 1 insert rows in a table inside a transaction.

客户端1在事务中插入表中的行。

Client 2 request this table with a SELECT. If on this client isolation level is set to READ COMMITTED, can you confirm that the SELECT won't returns the rows that aren't yet committed by Client 1.

客户机2使用SELECT请求此表。如果在此客户端隔离级别上设置为读取提交,您可以确认SELECT不会返回客户端1尚未提交的行。

Thanks

谢谢

3 个解决方案

#1


4  

It depends on the Transaction Isolation Level. If the Isolation Level is indeed 'Read Committed', other connections cannot see the rows that have been inserted by another client in a transaction that hasn't been committed yet.

它取决于事务隔离级别。如果隔离级别确实是“Read Committed”,则其他连接无法看到事务中尚未提交的另一个客户端插入的行。

Some reading:

一些阅读:

#2


1  

Yes, your statement is correct. READ COMMITTED specifies that statements cannot read data that has been modified but not committed by other transactions.

是的,你的陈述是正确的。READ COMMITTED指定语句不能读取被修改但未被其他事务提交的数据。

#3


1  

Correct.

正确的。

The MSDN reference for this is here which (quote) says:

MSDN对此的引用在这里(引用)说:

Specifies that statements cannot read data that has been modified but not committed by other transactions. This prevents dirty reads. Data can be changed by other transactions between individual statements within the current transaction, resulting in nonrepeatable reads or phantom data. This option is the SQL Server default.

指定语句不能读取已被修改但未被其他事务提交的数据。这可以防止脏读。数据可以通过当前事务中各个语句之间的其他事务进行更改,从而产生不可重复的读取或虚数据。这个选项是SQL Server默认值。

The SELECT would need to be running under READ UNCOMMITTED in order to read the data that has been modified by the other process, but not yet had the transaction committed.

SELECT将需要在READ UNCOMMITTED下运行,以便读取被其他进程修改过的数据,但是还没有提交事务。

#1


4  

It depends on the Transaction Isolation Level. If the Isolation Level is indeed 'Read Committed', other connections cannot see the rows that have been inserted by another client in a transaction that hasn't been committed yet.

它取决于事务隔离级别。如果隔离级别确实是“Read Committed”,则其他连接无法看到事务中尚未提交的另一个客户端插入的行。

Some reading:

一些阅读:

#2


1  

Yes, your statement is correct. READ COMMITTED specifies that statements cannot read data that has been modified but not committed by other transactions.

是的,你的陈述是正确的。READ COMMITTED指定语句不能读取被修改但未被其他事务提交的数据。

#3


1  

Correct.

正确的。

The MSDN reference for this is here which (quote) says:

MSDN对此的引用在这里(引用)说:

Specifies that statements cannot read data that has been modified but not committed by other transactions. This prevents dirty reads. Data can be changed by other transactions between individual statements within the current transaction, resulting in nonrepeatable reads or phantom data. This option is the SQL Server default.

指定语句不能读取已被修改但未被其他事务提交的数据。这可以防止脏读。数据可以通过当前事务中各个语句之间的其他事务进行更改,从而产生不可重复的读取或虚数据。这个选项是SQL Server默认值。

The SELECT would need to be running under READ UNCOMMITTED in order to read the data that has been modified by the other process, but not yet had the transaction committed.

SELECT将需要在READ UNCOMMITTED下运行,以便读取被其他进程修改过的数据,但是还没有提交事务。