数据库

Mysql 查看表锁SQL

By karp 9432 Views 3 MIN READ 0 Comments

Mysql 查看表锁SQL

SELECT 
  pr.id,
  pr.user,
  pr.host,
  pr.db,
  pr.command,
  pr.time,
  inn.trx_state,
  inn.trx_started,
  pr.info,
  tt.id,
  tt.user,
  tt.host,
  tt.command,
  tt.time,
  tt.trx_state,
  tt.trx_started,
  tt.info 
FROM
  information_schema.processlist pr,
  information_schema.innodb_trx inn,
  (SELECT 
    p.id,
    p.user,
    p.host,
    p.db,
    p.command,
    p.time,
    i.trx_state,
    i.trx_started,
    p.info,
    l.blocking_trx_id 
  FROM
    information_schema.processlist p,
    information_schema.innodb_trx i,
    information_schema.innodb_lock_waits l 
  WHERE p.id = i.trx_mysql_thread_id 
    AND i.trx_id = l.requesting_trx_id) tt 
WHERE pr.id = inn.trx_mysql_thread_id 
  AND inn.trx_id = tt.blocking_trx_id;

感谢DBA

本文由 karp 原创

采用 CC BY-NC-SA 4.0 协议进行许可

转载请注明出处:https://www.ikarp.top/index.php/archives/283.html

标签: mysql

0 评论