您好,欢迎访问一九零五行业门户网

mysql统计一张表中条目个数的方法_MySQL

统计一张表中条目的个通常的sql语句是:
select count(*) from tablename;#orselect count(1) from tablename;#or 统计一个列项,如idselect count(id)
另外,可通过使用information_schema统计个数
mysql中有一个名为 information_schema 的数据库,在该库中有一个 tables 表,这个表主要字段分别是:
table_schema : 数据库名
table_name:表名
engine:所使用的存储引擎
tables_rows:记录数
data_length:数据大小
index_length:索引大小
下面的sql语句给出了查询方法,同时也统计出了占用存储空间的信息:
select information_schema.`tables`.table_name, (data_length/1024/1024) as datam , (index_length/1024/1024) as indexm, ((data_length+index_length)/1024/1024) as allm, table_rowsfrom information_schema.`tables` where information_schema.`tables`.table_schema='abc';
其它类似信息

推荐信息