欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

mysql查詢鎖表的sql語句

謝彥文2年前8瀏覽0評論

MySQL中,查詢鎖表語句可以幫助我們查看指定鎖的鎖定情況,具體操作如下:

SELECT 
blocked_locks.requesting_trx_id AS blocking_id,
blocking_trx.trx_mysql_thread_id AS blocking_thread,
CONCAT(blocking_trx.trx_mysql_thread_id,':',blocking_trx.trx_query) AS blocking_query,
blocked_locks.blocking_pid AS blocked_id,
blocked_trx.trx_mysql_thread_id AS blocked_thread,
CONCAT(blocked_trx.trx_mysql_thread_id,':',blocked_trx.trx_query) AS blocked_query,
blocked_locks.lock_type AS lock_type,
blocked_locks.lock_mode AS lock_mode,
CONCAT(blocked_locks.lock_table_schema, '.', blocked_locks.lock_table_name) AS locked_table
FROM
information_schema.innodb_lock_waits AS blocked_locks
INNER JOIN
information_schema.innodb_trx AS blocked_trx ON blocked_locks.blocking_trx_id = blocked_trx.trx_id
INNER JOIN
information_schema.innodb_locks AS blocking_locks
INNER JOIN
information_schema.innodb_trx AS blocking_trx ON blocking_locks.lock_trx_id = blocking_trx.trx_id ON blocking_locks.lock_id = blocked_locks.requested_lock_id
WHERE
NOT blocking_locks.lock_type IS NULL;

在這條語句中,我們查詢了InnoDB鎖等待的所有必要信息,包括請求鎖的事務ID、被阻塞的事務ID、鎖定的表、鎖定的類型和鎖定的模式等。

我們可以通過對查詢結果進行分析,找到鎖定表的具體情況,以便通過解除鎖定等方式解決問題。