mysql查询数据总量引伸

本文详细介绍如何使用MySQL查询数据库中每张表的数据量、索引大小、行数等关键信息,同时提供统计数据库表数量及字段相关信息的方法。

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 = '表名';
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值