mysql数据库查数据表的大小和记录数
SELECT TABLE_NAME,DATA_LENGTH,INDEX_LENGTH,(DATA_LENGTH+INDEX_LENGTH) as length,TABLE_ROWS,concat(round((DATA_LENGTH+INDEX_LENGTH)/1024/1024,3), ‘MB’) as total_size FROM information_schema.TABLES WHERE TABLE_SCHEMA=’database_name’ order by length desc
说明:
TABLE_NAME :表名字;
DATA_LENGTH : 数据大小;
INDEX_LENGTH :索引大小;
TABLE_ROWS : 记录数量;
TABLE_SCHEMA : 数据库名字;
information_schema : 是mysql系统的库。