如何获取mysql数据库中每个表的大小?
1、查看每个库中表的大小,按大小排序
注意:表占用空间大小,包括 数据 和 索引
SELECT table_schema as `Database`, table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` FROM information_schema.TABLES ORDER BY (data_length + index_length) DESC;
查询结果
2、查看某个特定的库中,表的大小
SELECT table_schema as `Database`, table_name AS `Table`, round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` FROM information_schema.TABLES WHERE table_schema = "iuap_data_datafusion" # 替换为具体的库名 ORDER BY (data_length + index_length) DESC;
查询结果