mysql查看数据库单表占用空间大小

连上数据库

show databases;
+--------------------+
| Database               |
+--------------------+
| information_schema |
| photos                   |
| test                        |
+--------------------+

use information_schema ;

该库存储了所有数据的具体情况。

这条语句就是查询photos数据库中的albums_index_1表的具体数据大小和索引大小。

SELECT concat(round(sum(data_length/1024/1024),2),'MB') as data_length_MB, concat(round(sum(index_length/1024/1024),2),'MB') as index_length_MB  FROM information_schema.TABLES WHERE TABLE_SCHEMA='photos' AND TABLE_NAME='albums_index_1' ;

备忘。

原文地址:https://www.cnblogs.com/gaoj87/p/3579961.html