如何检查在表上持有的锁 [英] How to check which locks are held on a table

查看:118
本文介绍了如何检查在表上持有的锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何检查哪些数据库锁应用于查询批次的哪些行?

How can we check which database locks are applied on which rows against a query batch?

任何突出表行级锁定的工具实时?

Any tool that highlights table row level locking in real time?

DB:SQL Server 2005

DB: SQL Server 2005

推荐答案

响应, sp_lock 也可用于转储所有正在运行的进程的完整锁定信息。输出可能是压倒性的,但如果你想知道什么是锁定,它是一个有价值的运行。我通常与 sp_who2 一起使用它快速清零锁定问题。

To add to the other responses, sp_lock can also be used to dump full lock information on all running processes. The output can be overwhelming, but if you want to know exactly what is locked, it's a valuable one to run. I usually use it along with sp_who2 to quickly zero in on locking problems.

有多个不同版本的友好的 sp_lock 程序在线,取决于所讨论的SQL Server版本。

There are multiple different versions of "friendlier" sp_lock procedures available online, depending on the version of SQL Server in question.

SQL Server 2005, sp_lock 仍然可用,但已弃用,因此现在建议使用 sys.dm_tran_locks 查看此类事件。您可以找到一个如何滚动自己的sp_lock函数的示例此处

In your case, for SQL Server 2005, sp_lock is still available, but deprecated, so it's now recommended to use the sys.dm_tran_locks view for this kind of thing. You can find an example of how to "roll your own" sp_lock function here.

这篇关于如何检查在表上持有的锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆