mysql统计表大小

1
2
3
4
5
6
7
8
9
 
SELECT TABLE_NAME, concat( round( DATA_LENGTH / 1024 / 1024, 3),'MB') as 数据容量占用, concat( round( INDEX_LENGTH / 1024 / 1024, 3),'MB') as 索引容量占用, TABLE_ROWS
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = '数据库名称'
and TABLE_ROWS > 1
ORDER BY
TABLE_ROWS DESC