如何计算MySQL中数据库的总大小?) {: o- w- z1 a6 c- H
PS总大小,以正在使用的磁盘空间为单位。 2 ?5 _* P$ F: R$ ?+ ` 2 s- Q) k/ k1 B6 W' L 解决方案: , M: s1 H0 t, n1 Q* c+ P
这个链接有一个非常激烈的查询…将为您提供超出您需求的服务......:$ d# V8 I/ }- F- ~8 q4 Z
SELECT s.schema_name,CONCAT(IFNULL(ROUND((SUM(t.data_length) SUM(t.index_length)) .00)) total_size_in_MB,CONCAT(IFNULL(ROUND(((SUM(t.data_length) SUM(t.index_length))-SUM(t.data_free))/1024/1024,2),0.00)) data_used_IN_MB,CONCAT(IFNULL(ROUND(SUM(data_free)/1024/1024,2),0.00)) data_free_IN_MB,IFNULL(ROUND((((SUM(t.data_length) SUM(t.index_length))-SUM(t.data_free))/((SUM(t.data_length) SUM(t.index_length)))*100),2),0) pct_used,COUNT(table_name) total_tables FROM INFORMATION_SCHEMA.SCHEMATA s LEFT JOIN INFORMATION_SCHEMA.TABLES t ON s.schema_name = t.table_schema WHERE s.schema_name = 'abc' -- give your schema name GROUP BY s.schema_name ORDER BY pct_used DESC;