MySQL——查看数据库大小

前言

为了计算一些后面的扩展,所以看下当前业务数据的存储

步骤

所有的信息都存放在information_schema这个库里面,我们可以通过查询这个库中的数据来找到我们需要的数据。

查看所有库的数据和索引大小

select table_schema, concat(truncate(sum(data_length)/1024/1024/1024,2),' GB') as data_size,
concat(truncate(sum(index_length)/1024/1024/1024,2),'GB') as index_size
from information_schema.tables
group by table_schema
order by data_length desc;

猜你喜欢

转载自www.cnblogs.com/wangyang0210/p/13385892.html
今日推荐