在mysql中查看数据库与表的大小的方法

有需要的朋友,可以参考下
 

可以按如下的具体步骤,查询数据库的大小,如下:
1、进入information_schema 数据库(存放了其他的数据库的信息)
 

use information_schema;
 
 

2、查询所有数据的大小:
 

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;

 

3、查看指定数据库的大小,(比如查看数据库test_db的大小):
 

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='test_db';
 

4、查看指定数据库的某个表的大小(查看数据库test_db中 members 表的大小):
 

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='test_db' and table_name='members';
 5、查看每个数据库的大小
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables group by table_schema;

 

就介绍这些了,希望对大家有所帮助。

猜你喜欢

转载自guozhaoshun.iteye.com/blog/2199885