【查阅】mysql系统视图查看

【1】查看表大小

SELECT
    CONCAT(table_schema,'.',table_name) AS 'Table Name',
    table_rows AS 'Number of Rows',
    CONCAT(ROUND(data_length/(1024*1024),3),' MB') AS 'Data Size',
    CONCAT(ROUND(index_length/(1024*1024),3),' MB') AS 'Index Size',
    CONCAT(ROUND((data_length+index_length)/(1024*1024),3),' MB') AS 'Total Size'
FROM
    information_schema.TABLES
WHERE
    table_schema = 'test' AND table_name in ('test101','test102');

 【2】基本命令

【2.1】查看数据库版本:show variables like 'version';
【2.2】列出所有数据库:show databases;
【2.3】查看服务器状态:status;
【2.4】查看数据库存储引擎:show engines;
【2.5】查看数据库存储引擎插件:show plugins;
【2.6】查看数据库状态统计:show status;
【2.7】查看数据库参数:show variables;
【2.8】查看复制容灾:show master status; show slave status;
【2.9】查看单机还是集群:show variables like '%ckuster%';
【2.10】查看触发器,查看存储过程: show triggers;     show procedure status;
【2.11】查看当前mysql的线程:show process list;
【2.12】查看用户授权:show grants for root;
【2.13】更多
show table……
show index……
【2.14】查看当前会话的CRUD等次数:show status like 'com_%';
【2.15】查看字符集:show character set; show variables like 'character%';
【2.16】查看排序规则:show collation;
【2.17】查看数据库排序规则:show variables like 'collation%';

 【3】系统视图

3.1】查看字符集:select * from information_schema.character_sets;
【3.2】查看排序规则:select * from information_schema.collations;
原文地址:https://www.cnblogs.com/gered/p/10495044.html