查询MYSQL锁表情况

in 互联网技术 with 0 comment  访问: 227 次

1、列出当前在表缓存中打开的非临时表。
SHOW OPEN TABLES语法:

SHOW OPEN TABLES
    [{FROM | IN} db_name]
    [LIKE 'pattern' | WHERE expr]
mysql> show open tables from test like 'users';
+----------+-------+--------+-------------+
| Database | Table | In_use | Name_locked |
+----------+-------+--------+-------------+
| test     | users |      0 |           0 |
+----------+-------+--------+-------------+
1 row in set (0.00 sec)

SHOW OPEN TABLES显示打开的表输出列解释:

2、列出锁定的表

show open tables WHERE In_use > 0

例如检查tb_employees表是否被锁定:

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

参考:https://dev.mysql.com/doc/refman/5.6/en/show-open-tables.html

WeZan
Responses