-- 查询数据表占用空间大小,Top10 select TABLE_SCHEMA, TABLE_NAME , round(data_length/1024/1024,2) as DATA_LENGTH, round(index_length/1024/1024,2) as INDEX_LENGTH, round((data_length+index_length)/1024/1024,2) as TOTAL_LENGTH , TABLE_ROWS from information_schema.tables where TABLE_SCHEMA !='information_schema' and TABLE_SCHEMA !='mysql' order by total_length desc limit 10;
执行结果:
说明:
table_schema 数据库名称
table_name 数据表名称
data_length 表数据占用空间
index_length 表索引占用空间
table_rows 表记录数
加 where TABLE_SCHEMA !='information_schema' and TABLE_SCHEMA !='mysql' 是为了排除系统表。