假定要查的數據庫名稱是“xxxx_mall”
1、查看數據庫數據占用大小
select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from information_schema.TABLES where table_schema='xxxx_mall'
2、查看數據庫索引占用大小
select concat(round(sum(INDEX_LENGTH/1024/1024),2),'MB') as data from information_schema.TABLES where table_schema='xxxx_mall'
3、查看數據庫各個表的行數,索引大小,數據大小
select table_name,table_rows,concat(round((index_length)/1024/1024,2),'MB') index_data ,concat(round((data_length)/1024/1024,2),'MB') data_data
from information_schema.TABLES where table_schema='xxxx_mall'
4、查看各個數據庫的表個數
select count(*) tables, table_schema from information_schema.tables group by table_schema