下面两条命令只查询一个表,很快就能查询完
查询每个库的总大小并由大到小排序:
输出(库名,行数,数据容量,索引容量)
select
table_schema as '数据库',
sum(table_rows) as '总行数',
sum(truncate(data_length/1024/1024/1024, 2)) as '数据容量(GB)',
sum(truncate(index_length/1024/1024/1024, 2)) as '索引容量(GB)'
from information_schema.tables
group by table_schema
order by sum(data_length) desc, sum(index_length) desc;
查询某个库每个表的大小并由大到小排序:
输出(表名,数据容量,索引容量,行数)
select TABLE_NAME as 'table_name',
round((DATA_LENGTH)/1024/1024,2) as 'data_MB',
round((INDEX_LENGTH)/1024/1024,2) as 'index_MB',
TABLE_ROWS as rows
from information_schema.tables
where table_schema = '数据库名'
order by data_MB desc;