Is there a way to detect locked tables in MySQL? I mean tables locked by the LOCK TABLE table WRITE/READ
command.
(Note that readers interested in detecting named locks acquired with GET_LOCK
should read Show all current locks from get_lock instead.)
Use SHOW OPEN TABLES
:
http://dev.mysql.com/doc/refman/5.1/en/show-open-tables.html
You can do something like this
SHOW OPEN TABLES WHERE `Table` LIKE '%[TABLE_NAME]%' AND `Database` LIKE '[DBNAME]' AND In_use > 0;
to check any locked tables in a database.