MySQL查看数据库表容量大小的方法示例
本文介绍MySQL查看数据库表容量大小的命令语句,提供完整查询语句及实例,方便大家学习使用。
1.查看所有数据库容量大小
select table_schema as '数据库', sum(table_rows) as '记录数', sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)', sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)' from information_schema.tables group by table_schema order by sum(data_length) desc, sum(index_length) desc;
2.查看所有数据库各表容量大小
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 order by data_length desc, index_length desc;
3.查看指定数据库容量大小
例:查看mysql库容量大小
select table_schema as '数据库', sum(table_rows) as '记录数', sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)', sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)' from information_schema.tables where table_schema='mysql';
4.查看指定数据库各表容量大小
例:查看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='mysql' order by data_length desc, index_length desc;

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持免费资源网。
您可能感兴趣的文章
- 12-20使用DataGrip连接Hive的详细步骤
- 12-20debian10 mariadb安装过程详解
- 12-20MySQL索引失效的几种情况详析
- 12-20详解mysql持久化统计信息
- 12-20Robo可视化mongoDb实现操作解析
- 12-20MySQL 字段 LIKE 多个值
- 12-20Redis fork进程分配不到内存解决方案
- 12-20mysql插入前判断数据是否存在的操作
- 12-20基于navicat连接登录windows10本地wsl数据库
- 12-20Linux安装MariaDB数据库的实例详解


阅读排行
推荐教程
- 12-07mysql存储过程太慢怎么办
- 12-06redis通信协议(protocol)
- 12-05mysql的事务,隔离级别和锁用法实例分析
- 12-04MySQL一次性创建表格存储过程实战
- 12-03深入理解Redis内存淘汰策略
- 12-20PhpMyAdmin出现错误数据无法导出怎么办?
- 12-19Redis中实现查找某个值的范围
- 12-15浅析mysql迁移到clickhouse的5种方法
- 12-15CentOS7 64位下MySQL5.7安装与配置教程
- 12-14Mysql大型SQL文件快速恢复方案分享





