要想知道每个数据库的大小的话,步骤如下:
1、进入information_schema 数据库(存放了其他的数据库的信息)
mysql>use information_schema;
2、查询所有数据的大小:
mysql>select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;
3、查看指定数据库的大小:比如查看数据库 hdshop的大小
mysql>select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='hdshop';
4、查看指定数据库的某个表的大小: 比如查看数据库 hdshop 中 members 表的大小
mysql>select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='hdshop' and table_name='members';
5、mysql查看当前所有的数据库和索引大小
mysql>select table_schema,
concat(truncate(sum(data_length)/1024/1024,2),' mb') as data_size, concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
from information_schema.tables
group by table_schema
order by data_length desc;
6、mysql查看当前某个数据库和数据库下所有的表的大小
mysql>select table_name, concat(truncate(data_length/1024/1024,2),' MB') as data_size,concat(truncate(index_length/1024/1024,2),' MB') as index_size
from information_schema.tables where table_schema = 'hdshop'
group by table_name
order by data_length desc;
网友评论