原文链接:https://blog.csdn.net/fdipzone/article/details/80144166
4.查看指定数据库各表容量大小
例:查看mysql库各表容量大小
select table_schema as 'dbname',table_name as 'tname',table_rows as 'recordnum',truncate(data_length/1024/1024, 2) as 'size(MB)',truncate(index_length/1024/1024, 2) as 'indexsize(MB)' from information_schema.tables where table_schema='dbname' order by data_length desc, index_length desc;

3.查看指定数据库容量大小
例:查看mysql库容量大小
select table_schema as 'dbname', sum(table_rows) as 'recordnum', sum(truncate(data_length/1024/1024, 2)) as 'dbsize(MB)', sum(truncate(index_length/1024/1024, 2)) as 'indexsize(MB)' from information_schema.tables where table_schema='dbname';