【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;