MySQL查看单个表,所有表数据大小

查询表所属schema,mysql中一般schema等于database名

SELECT * FROM information_schema.COLUMNS WHERE table_name = 'student';

查看单个表大小

select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') as table_size 
from information_schema.tables where table_schema='study' AND table_name='student';

查看某个库下面所有的表大小

select 
    table_name,
    (select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') as table_size from information_schema.tables     where table_schema='study' AND table_name=tbs.table_name) as table_size 
from (select table_name from information_schema.tables where table_schema='study') as tbs;

猜你喜欢

转载自blog.csdn.net/weixin_43073775/article/details/121215688