MySQL 查看数据库中每个表占用的空间大小

转自:http://www.oschina.net/question/12_3673

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

mysql> use information_schema;
Database changed

2、查询所有数据的大小

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

3、查看指定数据库实例的大小,比如说数据库 forexpert

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

4、查看指定数据库的表的大小,比如说数据库 forexpert 中的 member 表 

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

相关推荐

6 thoughts on “MySQL 查看数据库中每个表占用的空间大小”

Leave a Comment