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查询特定数据库中所有表的索引大小及数据大小,包括使用SQL语句的具体方法。
10万+

被折叠的 条评论
为什么被折叠?



