sql语句查看MySQL数据库大小
2016-04-29 18:58
477 查看
SQL语句查看MySQL数据库大小
查看MySQL表大小例子:查看hellodb数据库,只显示出zabbix库中最大的10个表
参考链接:http://www.ttlsa.com/mysql/mysql-howto-find-the-database-and-table-size/
> SELECT table_schema "Database Name", sum( data_length + index_length ) / 1024 / 1024 "Database Size in MB" FROM information_schema.TABLES GROUP BY table_schema; +--------------------+---------------------+ | Database Name | Database Size in MB | +--------------------+---------------------+ | o2o | 12.13803768 | | hellodb | 0.09472656 | | information_schema | 0.15625000 | | jumpserver | 1.46875000 | | mysql | 0.75833321 | | performance_schema | 0.00000000 | +--------------------+---------------------+ 6 rows in set (0.04 sec)
查看MySQL表大小例子:查看hellodb数据库,只显示出zabbix库中最大的10个表
> SELECT table_name AS "Tables",round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "www_ttlsa_com" ORDER BY (data_length + index_length) DESC; +----------+------------+ | Tables | Size in MB | +----------+------------+ | classes | 0.02 | | toc | 0.02 | | teachers | 0.02 | | students | 0.02 | | scores | 0.02 | | courses | 0.02 | | t2 | 0.00 | +----------+------------+ 7 rows in set (0.00 sec)找出前10的表大小
> SELECT CONCAT(table_schema, '.', table_name), CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows, CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA, CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx, CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size, ROUND(index_length / data_length, 2) idxfrac FROM information_schema.TABLES ORDER BY data_length + index_length DESC LIMIT 10;
+---------------------------------------+-------+-------+-------+------------+---------+ | CONCAT(table_schema, '.', table_name) | rows | DATA | idx | total_size | idxfrac | +---------------------------------------+-------+-------+-------+------------+---------+ | zabbix.history_uint | 1.97M | 0.12G | 0.05G | 0.17G | 0.44 | | zabbix.history | 1.60M | 0.09G | 0.04G | 0.13G | 0.47 | | XX_Mobile.banklisttest | 0.06M | 0.01G | 0.00G | 0.01G | 0.00 | | zabbix.events | 0.03M | 0.00G | 0.00G | 0.01G | 1.60 | | XXXXfenxiao.pigcms_wechat_group_list | 0.04M | 0.00G | 0.00G | 0.00G | 0.15 | | XXXXfenxiao.pigcms_behavior | 0.03M | 0.00G | 0.00G | 0.00G | 0.60 | | b2b.ecs_stats | 0.05M | 0.00G | 0.00G | 0.00G | 0.13 | | XX_Mobile.create_sn | 0.02M | 0.00G | 0.00G | 0.00G | 0.58 | | b2b.ecs_goods | 0.00M | 0.00G | 0.00G | 0.00G | 0.04 | | zabbix.trends_uint | 0.02M | 0.00G | 0.00G | 0.00G | 0.00 | +---------------------------------------+-------+-------+-------+------------+---------+ 10 rows in set (0.14 sec)
参考链接:http://www.ttlsa.com/mysql/mysql-howto-find-the-database-and-table-size/
相关文章推荐
- mysql循环存储
- C# 使用mysql.data.dll,读写mysql数据库
- mysql 用 @rownum := @rownum+1 实现 rownum 功能
- 20140429mysql给用户赋予所有权限
- mysql常用命令
- mysql常用命令
- 错误码:2003 不能连接到 MySQL 服务器在 (10061)
- MySQL运算符和函数
- MYSQL 下载与安装
- 利用XtraBackup做mysql不停机重做主从复制 推荐
- MySQL压缩包安装
- mysql
- mysql
- 20140429Ubuntu系统上的mysql中文乱码
- MySQL 对比数据库表结构
- Navicat for mysql 中文乱码问题
- mysql 搭建读写分离(Amoeba)
- mysql分组取每组前几条记录(排名) 附group by与order by的研究
- MySQL 约束条件
- mysql 获取某个时间段每一天的统计数据