mysql统计某一数据库中每张表存储的数据量
select table_name, (data_length/1024/1024) `data`, (index_length/1024/1024) `index`, ((data_length + index_length)/1024/1024) `all`, table_rows from information_schema.tables where table_schema = '数据库名' order by table_rows;
information_schema 是当前数据连接下的数据库,它的 tables 表用于记录数据库表的一些信息,其中:table_schema 代表数据库名,table_name 代表表名,engine 代表存储引擎,row_format 代表行记录格式,table_rows 代表行数,avg_row_length 代表平均每行包括的字节数,data_length 代表表的数据量,max_data_length代表最大数据量,index_length 代表索引空间……
查询当前数据连接中每个数据库的表数量
select count(*) `tables`, table_schema from information_schema.tables group by table_schema;
# 具体某一数据库的表数量
select count(*) `tables`, table_schema from information_schema.tables where table_schema = '数据库名';
查询数据库中表的字段相关信息
select table_name, column_name, data_type, column_comment from information_schema.columns where table_schema = '数据库名';
# 具体某张表的字段数量
select count(*) from information_schema.columns where table_schema = '数据库名' and table_name = '表名';
本文详细介绍如何使用MySQL查询数据库中每张表的数据量、索引大小、行数等关键信息,同时提供统计数据库表数量及字段相关信息的方法。
4万+

被折叠的 条评论
为什么被折叠?



