您的当前位置:首页正文

mysql如何查询数据库的大小

2020-11-09 来源:画鸵萌宠网

相关学习推荐:mysql数据库

mysql查询数据库的大小的方法:

1、查询整个mysql数据库,整个库的大小;单位转换为MB。

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from information_schema.TABLES

e07c9ba4a756c319b7d35dba7c7329d.png

2、查询mysql数据库,某个库的大小;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data 
 from information_schema.TABLES
 where table_schema = 'testdb'

90f4979023e417062906b526dd04be4.png

3、查看库中某个表的大小;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data 
 from information_schema.TABLES
 where table_schema = 'testdb'
 and table_name = 'test_a';

a0a2e8fe34e7f3ffecf4cb3b1edc9d9.png

4、查看mysql库中,test开头的表,所有存储大小;

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data 
 from information_schema.TABLES
 where table_schema = 'testdb'
 and table_name like 'test%';

6f4874751419c47db898dcc82166601.png

Top