一. 概述
查看mysql库中,各个表的记录数、数据容量、索引容量
二. 查询语句
select
table_schema as '数据库',
table_name as '表名',
table_rows as '记录数',
truncate(data_length/1024/1024, 2) as '数据容量(MB)',
truncate(index_length/1024/1024, 2) as '索引容量(MB)'
from information_schema.tables
where table_schema='dbname'
order by table_rows desc, index_length desc;
三. 查询表数量
select count(table_name)
from information_schema.tables
where table_schema='dbname'
本文档介绍了如何使用SQL查询MySQL数据库中各表的记录数、数据容量和索引容量,通过'information_schema.tables'表实现,同时统计了表的数量。重点在于数据库管理和维护的实践技巧。
3201

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



