在mysql查询中获取锁定表 [英] Get locked tables in mysql query

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

问题描述

是否可以通过MySQL查询获取锁定表?我有一个正在运行的C#线程应用程序,并且有一堆表被锁定在该应用程序中.

Is there any way via a MySQL query to get the locked tables? I have a C# threading application running and there are bunch of tables getting locked in the app.

我需要查看锁定的表并分析可能对其进行锁定的代码.

I need to see the locked tables and analyze the code that could be locking it.

推荐答案

使用:

SHOW OPEN TABLES

检查列In_use是否大于0.在这种情况下,表被锁定.

An check whether the column In_use is greater than 0. In that case, the table is locked.

  • 锁定表列表:

  • List of locked tables:

show open tables WHERE In_use > 0

检查表tb_employees是否已锁定:

show open tables WHERE Table LIKE 'tb_employees' AND In_use > 0

官方文档:

In_use

In_use

表锁的数量或 该表有锁定请求. 例如,如果一个客户获得了 使用LOCK TABLE t1锁定表 WRITE,In_use将为1.如果另一个 客户端发出LOCK TABLE T1 WRITE 当桌子保持锁定状态时, 客户端将阻止等待 锁定,但锁定请求导致 In_use为2.如果计数为零, 该表已打开,但当前未打开 正在使用.使用量也增加了 由HANDLER ... OPEN语句和 由HANDLER减少... CLOSE.

The number of table locks or lock requests there are for the table. For example, if one client acquires a lock for a table using LOCK TABLE t1 WRITE, In_use will be 1. If another client issues LOCK TABLE t1 WRITE while the table remains locked, the client will block waiting for the lock, but the lock request causes In_use to be 2. If the count is zero, the table is open but not currently being used. In_use is also increased by the HANDLER ... OPEN statement and decreased by HANDLER ... CLOSE.

这篇关于在mysql查询中获取锁定表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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