MySQL中查看某数据库大小及表大小

查看指定表的大小
select concat(round(sum(DATA_LENGTH/1024/1024),2),‘MB’) as data from information_schema.TABLES where table_schema=‘库名’ and table_name=‘表名’;
在这里插入图片描述

查看指定数据库的大小
select concat(round(sum(DATA_LENGTH/1024/1024),2),‘MB’) as data from information_schema.TABLES where table_schema=‘库名’;
在这里插入图片描述

查看所有表大小并排序
SELECT CONCAT(table_schema,’.’,table_name) AS ‘Table Name’, CONCAT(ROUND(table_rows/1000000,4),‘M’) AS ‘Number of Rows’, CONCAT(ROUND(data_length/(102410241024),4),‘G’) AS ‘Data Size’,CONCAT(ROUND(index_length/(102410241024),4),‘G’) AS ‘Index Size’, CONCAT(ROUND((data_length+index_length)/(102410241024),4),‘G’) AS’Total’FROM information_schema.TABLES ORDER BY --total DESC;
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/u014609263/article/details/88863486