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 ;

猜你喜欢

转载自www.cnblogs.com/exmyth/p/9140182.html