mysql 数据库磁盘占用量统计

查看某个表的磁盘占用量

select 
    (data_length+index_length)/1024/1024 M 
from 
    information_schema.tables 
where 
    table_schema="db_name" and table_name='table_name';

查看整个数据库的磁盘用量

select 
    sum((data_length+index_length)/1024/1024) M
from 
    information_schema.tables 
where 
    table_schema="db_name" ;

 

查看整个mysql server 所有数据库的磁盘用量

select 
    table_schema, sum((data_length+index_length)/1024/1024) M
from 
    information_schema.tables 
where 
    table_schema is not null 
group by 
    table_schema ;

 

posted @ 2018-06-05 15:51  牧之丨  阅读(606)  评论(0编辑  收藏  举报