#查所有据库的表大小(全部)
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.tablesorder by data_length desc, index_length desc;
# 查看单个数据库大小
select table_schema as '数据库名',sum(table_rows) as '记录数',sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'from information_schema.tables where table_schema='dbname';
查看指定表的大小
use information_schema; #进入这个表后查询
select concat(round(sum(data_length/1024/1024),2),'MB') as '数据容量(MB)',
concat(round(sum(index_length/1024/1024),2),'MB') as '索引容量(MB)'
from tables where table_schema='dbname' and table_name = 'tablename';
MySQL查看库的大小
最新推荐文章于 2024-05-31 17:25:23 发布