mysql> select table_schema, concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES group by table_schema;
查询指定库,指定表的大小:
mysql> select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from TABLES where table_schema='test' and table_name='tx1';
+--------+
| data |
+--------+
| 0.02MB |
+--------+
1 row in set (0.00 sec)
查询指定库,索引的大小:
mysql> SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ' MB') AS 'Total Index Size' FROM TABLES WHERE table_schema ='tx1' ;
+------------------+
| Total Index Size |
+------------------+
| NULL |
+------------------+
1 row in set (0.00 sec)