查看所有库的总量
select
-> concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as ALL_DB_DATA_SIZE,
-> concat(round(sum(INDEX_LENGTH/1024/1024),2),'MB') as ALL_DB_INDEX_SIZE,
-> concat(round(sum((DATA_LENGTH + INDEX_LENGTH)/1024/1024),2),'MB') as ALL_DB_TOTAL_SIZE
-> from information_schema.TABLES;
查看库的大小并进行排序
select
-> table_schema as DB_NAME,
-> concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as DB_DATA_SIZE,
-> concat(round(sum(INDEX_LENGTH/1024/1024),2),'MB') as DB_INDEX_SIZE,
-> concat(round(sum((DATA_LENGTH + INDEX_LENGTH)/1024/1024),2),'MB') as DB_TOTAL_SIZE
-> from information_schema.TABLES
-> group by table_schema
-> order by sum(DATA_LENGTH + INDEX_LENGTH) desc;
转载: