mysql 数据库或者表空间使用查询

直接上语句

查所有数据库占用空间大小

select TABLE_SCHEMA, concat(truncate(sum(data_length)/1024/1024,2),' MB') as data_size,

concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size

from information_schema.tables

group by TABLE_SCHEMA

order by data_length desc;

 

查指定数据库占用空间大小

select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB') as data_size,

concat(truncate(index_length/1024/1024,2),' MB') as index_size

from information_schema.tables where TABLE_SCHEMA = 'im_db'

group by TABLE_NAME

order by data_length desc;

posted @ 2017-10-23 11:16  itbread  阅读(6032)  评论(0编辑  收藏  举报

如果觉得对你有帮助,不妨微信扫描打赏鼓励下