MYSQL查看表与库的容量大小

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MYSQL查看表与库的容量大小相关的知识,希望对你有一定的参考价值。


查看表的容量大小
mysql> use information_schema;
select data_length,index_length
from tables where
table_schema='test'
 and table_name = 'test_table';

#字节转MB
select concat(round(sum(data_length/1024/1024),2),'MB') as data_size_mb,
concat(round(sum(index_length/1024/1024),2),'MB') as  index_size_mb
from tables where
table_schema='test'
and table_name = 'test_table';


查看库的容量大小
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;


以上是关于MYSQL查看表与库的容量大小的主要内容,如果未能解决你的问题,请参考以下文章

MySQL查看数据库表容量大小

MySQL 查看数据库容量大小

Mysql查看数据库表容量大小

查看mysql数据库容量大小

查看mysql数据库容量大小

MySql--库的操作