Detecting locked tables (locked by LOCK TABLE)

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.


You can use SHOW OPEN TABLES to show each table's lock status. More details on the command's doc page are here.


SHOW OPEN TABLES to show each table status and its lock.

For named locks see Show all current locks from get_lock