SQL运维操作
连接数据库
mysql -h172.16.17.208 -uwanwan -pwanwan -P3306
数据库连接相关操作
#查询mysql连接
SELECt * FROM information_schema.processlist t;
#批量删除连接
SELECt concat('KILL ',id,';') FROM information_schema.processlist t;
查询所有表名
SELECt
table_name 表名,
table_comment 表注释,
table_rows 数据量
FROM information_schema.tables
WHERe table_schema = 'feedback'
AND table_comment LIKE '%工单%'
ORDER BY table_name;
查询指定表所有字段
SELECt
column_name 字段名,
column_comment 字段注释,
column_type 字段类型
FROM information_schema.columns
WHERe table_name='bad_eval_work_order'
AND table_schema='csfeedback';
查询所有表名和字段
SELECt
a.table_name 表名,
a.table_comment 表注释,
b.column_name 表字段,
b.column_type 字段类型,
b.column_comment 字段注释
FROM information_schema.tables a LEFT JOIN information_schema.columns b ON b.table_name = a.table_name
WHERe 1=1
AND a.table_schema='csfeedback';