mysql查看数据库大小,索引大小

select concat(round(sum(index_LENGTH)/(1024*1024),2),'MB') as 'Index Size' from tables where table_schema='usertest';

mysql> use information_schema
Database changed

mysql> select concat(round(sum(index_LENGTH)/(1024*1024),2),'MB') as 'Index Size' from tables where table_schema='bbs'; 
+-----------+
| Index Size |
+-----------+
| 0.00MB    | 
+-----------+
1 row in set (0.01 sec)
解释:
concat和“MB”是单位
round和2表明精确2位小数
sum表明所有的索引相加
table_schema='bbs' bbs就是你要统计的数据库

mysql> select concat(round(sum(data_LENGTH)/(1024*1024),2),'MB') as 'Data Size' from tables where table_schema='bbs'; 
+-----------+
| Data Size |
+-----------+
| 4.34MB    | 
+-----------+
1 row in set (0.01 sec)

你可能感兴趣的:(mysql)