#查看每个数据库所占磁盘大小
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;
原文地址:https://www.cnblogs.com/yanglei-xyz/p/10333739.html
时间: 2024-10-08 20:16:03