mysql查看每个数据库所占磁盘大小
Posted yanglei.xyz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql查看每个数据库所占磁盘大小相关的知识,希望对你有一定的参考价值。
#查看每个数据库所占磁盘大小
SELECT TABLE_SCHEMA AS "库名", TRUNCATE(SUM(`DATA_LENGTH`) / 1024 / 1024, 2) AS "表所占空间(MB)", TRUNCATE(SUM(`INDEX_LENGTH`) / 1024 / 1024, 2) AS "索引所占空间(MB)", TRUNCATE((SUM(`DATA_LENGTH`) + SUM(`INDEX_LENGTH`)) / 1024 / 1024,2) AS "空间累计(MB)" FROM information_schema.`TABLES` GROUP BY `TABLE_SCHEMA`;
#查看某个数据库各表所占磁盘大小
SELECT TABLE_NAME, TRUNCATE (DATA_LENGTH / 1024 / 1024, 2) AS "DATA_SIZE(MB)", TRUNCATE (INDEX_LENGTH / 1024 / 1024, 2) AS "INDEX_SIZE(MB)" FROM INFORMATION_SCHEMA. TABLES WHERE TABLE_SCHEMA = ‘db_name‘ GROUP BY TABLE_NAME ORDER BY DATA_LENGTH DESC;
以上是关于mysql查看每个数据库所占磁盘大小的主要内容,如果未能解决你的问题,请参考以下文章