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

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

WBOY
WBOYOriginal
2016-06-07 16:41:351381browse

转自: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 da

转自: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)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn