查看Mysql数据库大小

数据库 piniu 781浏览 0评论

1、进去指定schema 数据库(存放了其他的数据库的信息)

mysql> use information_schema;

2、查询所有数据的大小   

mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2), 'MB') as data from TABLES;
+--------+
| data   |
+--------+
| 8.65MB | 
+--------+
1 row in set (0.15 sec)

3、查看指定数据库的大小 
如:数据库cacti

mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2), 'MB') as data from TABLES where table_schema= 'cacti' ;     
+--------+
| data   |
+--------+
| 8.07MB | 
+--------+
1 row in set (0.14 sec)

4、查看指定数据库的表的大小
如:查看数据库cacti 中npc_timedevents 表的大小

mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2), 'MB') as data from TABLES where table_schema= 'cacti' and table_name= 'npc_timedevents' ;
+--------+
| data   |
+--------+
| 4.02MB | 
+--------+
1 row in set (0.00 sec)

5、查询数据库中哪些表数据量比较大

mysql> select table_name,concat(round(DATA_LENGTH/1024/1024,2), 'MB') as data from tables order by DATA_LENGTH desc limit 10;
+-----------------------------+--------+
| table_name                  | data   |
+-----------------------------+--------+
| npc_timedevents             | 4.02MB | 
| npc_servicechecks           | 2.52MB | 
| help_topic                  | 0.37MB | 
| npc_hostchecks              | 0.28MB | 
| npc_notifications           | 0.17MB | 
| npc_logentries              | 0.09MB | 
| help_keyword                | 0.08MB | 
| graph_templates_item        | 0.02MB | 
| help_category               | 0.02MB | 
| npc_hostescalation_contacts | 0.02MB | 
+-----------------------------+--------+
10 rows in set (0.13 sec)

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • * 昵称:
  • * 邮箱: