(单位: M)
SELECt round( sum( data_length / 1024 / 1024 ), 2 ) AS size FROM information_schema.TABLES;
.
.
(单位: M)
SELECt table_schema, round( sum( data_length / 1024 / 1024 ), 2 ) AS size FROM information_schema.TABLES GROUP BY table_schema ORDER BY size DESC;三. 查询mysql中某库下没张表占用的空间大小
mysql> SELECt
-> table_schema AS '数据库',
-> table_name AS '表名',
-> table_rows AS '记录数',
-> TRUNCATE ( data_length / 1024 / 1024, 2 ) AS '数据容量(MB)',
-> TRUNCATE ( index_length / 1024 / 1024, 2 ) AS '索引容量(MB)'
-> FROM
-> information_schema.TABLES
-> WHERe
-> table_schema = 'maxwell'
-> ORDER BY
-> table_rows DESC;
+---------+------------+--------+--------------+--------------+
| 数据库 | 表名 | 记录数 | 数据容量(MB) | 索引容量(MB) |
+---------+------------+--------+--------------+--------------+
| maxwell | columns | 79253 | 5.51 | 3.03 |
| maxwell | tables | 4482 | 0.31 | 0.18 |
| maxwell | schemas | 3575 | 45.51 | 0.37 |
| maxwell | databases | 154 | 0.01 | 0.01 |
| maxwell | positions | 22 | 0.01 | 0.00 |
| maxwell | heartbeats | 22 | 0.01 | 0.00 |
| maxwell | bootstrap | 0 | 0.01 | 0.00 |
+---------+------------+--------+--------------+--------------+
7 rows in set (0.06 sec)



