2

I am very new to SQL. I am using SQL Server 2008 R2. I have following issues;

(1)

A transaction has started but its commit point is not reached.

UPDATE Student 
SET subject = 'Technology' 
WHERE subjectCode = 'tech';

When this is executing what type of locking is having full table/row??

(2)

Is there is a way to get locks held by a transaction?

4

1 回答 1

2

答案(1):

如果事务没有被任何预先存在的锁阻塞,那么Student表中所有带有 a 的行subjectCode = 'tech'现在都将拥有一个(X)(独占)锁。

在页面和表级别,将有(IX)(意图排他)锁 - 表明在“层次结构”(表 -> 页面 -> 行)的更下方的某个地方存在排他锁。

如果您要更新超过 5000 行,则锁升级将启动,并且 SQL Server 已将 5000 多个单独的行级排他锁替换为单个表级排他锁。这意味着基本上没有人可以对那张桌子做任何事情。

对于您的问题 (2) -请参阅其他 SO question 的答案

于 2013-04-23T20:41:11.653 回答