shanghaipc 发表于 2016-10-25 01:32:22

统计mysql数据库每个库的大小,表总数等

作用:统计每个库的真实数据与索引数据的总和的大小单位为MB,真实数据的大小单位MB,索引数据的大小MB,含有表的总数,当前日期。并且以每个库的大小倒序排序。

 
SELECT   table_schema,\
SUM(data_length+index_length)/1024/1024 AS total_mb,\
SUM(data_length)/1024/1024 AS data_mb,\
SUM(index_length)/1024/1024 AS index_mb,\
COUNT(*) AS tables,\
CURDATE() AS today \
FROM   information_schema.tables \
GROUP BY table_schema \
ORDER BY 2 DESC;
 

 
页: [1]
查看完整版本: 统计mysql数据库每个库的大小,表总数等