WB
WB
文章目录
  1. 1. Mysql

(no title)

Mysql

  1. 查看所有表表名和备注
1
2
3
4
SELECT TABLE_NAME,
table_comment
FROM `information_schema`.tables
WHERE table_schema='数据库名'
  1. 查询某张表的字段和备注
1
2
3
4
5
select column_name,
column_comment
from information_schema.columns
where table_name ='表名'
and table_schema='数据库名'
  1. 查看所有字段名称和备注
1
2
3
4
5
6
7
8
9
10
SELECT a.table_name,
a.column_name,
a.column_comment
FROM information_schema.columns a,
`information_schema`.tables b
WHERE a.table_name = b.table_name
AND a.table_schema = b.table_schema
AND a.table_schema='数据库名'
ORDER BY a.table_name,
a.ordinal_position;
  1. 处理死锁问题
    1
    2
    3
    4
    5
    6
    7
    8
    SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS; 
    SHOW OPEN TABLES WHERE In_use > 0; //查询死锁
    SELECT * FROM information_schema.INNODB_TRX; //查询死锁id
    kill 33614 //杀死

    show processlist;

    SHOW ENGINE INNODB STATUS; //查询最近一次的死锁日志
支持一下
扫一扫,支持一下
  • 微信扫一扫
  • 支付宝扫一扫