[英]Does TRANSACTION ISOLATIoN LEVEL SERIALIZABLE create READ lock
I can't seem to find a straight answer on what should be a simple question. 对于什么是简单的问题,我似乎找不到直接的答案。 If I create a transaction in T-SQL and set the ISOLATION LEVEL to SERIALIZABLE, does this create a READ lock on the tables that I am modifying?
如果我在T-SQL中创建事务并将ISOLATION LEVEL设置为SERIALIZABLE,这是否在我正在修改的表上创建了READ锁?
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
GO
BEGIN TRANSACTION;
GO
TRUNCATE TABLE TBL_PRODUCTS;
GO
**INSERT RECORDS HERE**
GO
COMMIT TRANSACTION;
GO
TRUNCATE TABLE
will acquire a
exclusive
shema modify lock on the table preventing all users from reading from the table
(unless they use
and writing to the table (no exceptions for writing). TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
or
WITH(NOLOCK)
)
TRUNCATE TABLE
将获得TRUNCATE TABLE
的
独占
shema修改锁,以防止所有用户从表中读取
(除非他们使用
并写入表(写入时没有例外)。 The exclusive lock will be released at TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
或
WITH(NOLOCK)
)
COMMIT TRANSACTION
. 排他锁将在
COMMIT TRANSACTION
释放。
EDIT: As Martin Smith pointed out in his comment below the truncate table will acquire a schema modify lock. 编辑:正如马丁·史密斯(Martin Smith)在其truncate表下方的注释中指出的那样,它将获得一个模式修改锁。 Meaning there are no other user will be able to read or modify the table whatsoever until a commit or rollback has taken place.
意味着在进行提交或回滚之前,没有其他用户可以读取或修改表。
Yes, it will lock the table, and these are the rules for serializable: 是的,它将锁定表,这些是可序列化的规则:
https://msdn.microsoft.com/en-us/library/ms173763.aspx https://msdn.microsoft.com/en-us/library/ms173763.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.