gpt4 book ai didi

sql-server - 如何检查 SQL 表是否被锁定以供查询?

转载 作者:行者123 更新时间:2023-12-02 01:07:22 24 4
gpt4 key购买 nike

无论出于何种原因,数据库中的一个特定表开始无法完成对特定表的任何查询结果。它显示“正在执行查询...”但未完成。

喜欢:

select * from foo

其他表正在返回行。

如何/在哪里可以检查表是否已锁定?

最佳答案

检查这个样本

    select  
object_name(P.object_id) as TableName
, resource_type
, resource_description
, request_mode
, CASE REQUEST_MODE
WHEN 'S' THEN 'Shared'
WHEN 'U' THEN 'Update'
WHEN 'X' THEN 'Exclusive'
WHEN 'IS' THEN 'Intent Shared'
WHEN 'IU' THEN 'Intent Update'
WHEN 'IX' THEN 'Intent Exclusive'
WHEN 'SIU' THEN 'Shared Intent Update'
WHEN 'SIX' THEN 'Shared Intent Exclusive'
WHEN 'UIX' THEN 'Update Intent Exclusive'
WHEN 'BU' THEN 'Bulk Update'
WHEN 'RangeS_S' THEN 'Shared Range S'
WHEN 'RangeS_U' THEN 'Shared Range U'
WHEN 'RangeI_N' THEN 'Insert Range'
WHEN 'RangeI_S' THEN 'Insert Range S'
WHEN 'RangeI_U' THEN 'Insert Range U'
WHEN 'RangeI_X' THEN 'Insert Range X'
WHEN 'RangeX_S' THEN 'Exclusive range S'
WHEN 'RangeX_U' THEN 'Exclusive range U'
WHEN 'RangeX_X' THEN 'Exclusive range X'
WHEN 'SCH-M' THEN 'Schema-Modification'
WHEN 'SCH-S' THEN 'Schema-Stability'

ELSE NULL
END AS REQUEST_LOCK_MODE

FROM sys.dm_tran_locks AS L
join sys.partitions AS P
on L.resource_associated_entity_id = p.hobt_id

编号:http://sqlblog.foxraven.com/2012/01/check-to-see-if-table-is-locked.html

关于sql-server - 如何检查 SQL 表是否被锁定以供查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21093616/

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