mysql 数据库磁盘占用量统计

时间:2023-03-10 04:54:16
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 ;