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