mysql查看数据库大小

1、查看全库大小

1 select table_schema as '数据库',
2        sum(table_rows) as '记录数',
3        sum(truncate(data_length / 1024 / 1024, 2)) as '数据容量(MB)',
4        sum(truncate(index_length / 1024 / 1024, 2)) as '索引容量(MB)'
5   from information_schema.tables
6  group by table_schema
7  order by sum(data_length) desc, sum(index_length) desc;

 

2、查看指定数据库大小

1 select table_schema as '数据库',
2        sum(table_rows) as '记录数',
3        sum(truncate(data_length / 1024 / 1024, 2)) as '数据容量(MB)',
4        sum(truncate(index_length / 1024 / 1024, 2)) as '索引容量(MB)'
5   from information_schema.tables
6  where table_schema = 'mysql';

 

3、查看全库表大小

1 select table_schema as '数据库',
2        table_name as '表名',
3        table_rows as '记录数',
4        truncate(data_length / 1024 / 1024, 2) as '数据容量(MB)',
5        truncate(index_length / 1024 / 1024, 2) as '索引容量(MB)'
6   from information_schema.tables
7  order by data_length desc, index_length desc;

 

 4、查看指定库表大小

1 select table_schema as '数据库',
2        table_name as '表名',
3        table_rows as '记录数',
4        truncate(data_length / 1024 / 1024, 2) as '数据容量(MB)',
5        truncate(index_length / 1024 / 1024, 2) as '索引容量(MB)'
6   from information_schema.tables
7  where table_schema = 'mysql'
8  order by data_length desc, index_length desc;

 

posted @ 2018-07-25 14:26  用铅笔写日记  阅读(111)  评论(0)    收藏  举报