bitscn.com
如果想知道mysql数据库中每个表占用的空间、表记录的行数的话,可以打开mysql的 information_schema 数据库。在该库中有一个 tables 表,这个表主要字段分别是:
table_schema : 数据库名
table_name:表名
engine:所使用的存储引擎
tables_rows:记录数
data_length:数据大小
index_length:索引大小
其他字段请参考mysql的手册,我们只需要了解这几个就足够了。
所以要知道一个表占用空间的大小,那就相当于是 数据大小 + 索引大小 即可。
sql:
select table_name,data_length+index_length,table_rows from tables where table_schema='数据库名' and table_name='表名'
作者“越特”
bitscn.com