Mysql 查看数据库各表容量大小
2023-09-27 14:29:10 时间
本文介绍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;
相关文章
- 【数据库开发】is not allowed to connect to this MySQL server解决办法
- mysql查看数据库
- mysql数据库默认存放位置修改
- 数据库-mysql安装和配置
- mysql的Navicat查看数据库的ER图
- MYSQL数据库链接层- SUMMER-SQL
- mysql对json后的值进行查询
- mybatis中mysql和oracle的差异
- java+s2sh+mysql音乐网站
- MySQL日期、字符串、时间戳互转
- [数据库]MySQL解决:MySQLNonTransientConnectionException: Could not create connection to database server.【待完善】
- mysql 与elasticsearch实时同步常用插件及优缺点对比(ES与关系型数据库同步)
- mysql和oracle的区别(功能性能、选择、使用它们时的sql等对比)
- 查看mysql数据库及表编码格式
- 超全面的JavaWeb笔记day15<mysql数据库>
- mysql查看表使用的数据库引擎
- mysql prepare语句使用
- 关于MySQL存储IP地址引发的思考
- mysql数据库对时间进行默认的设置
- 开源数据库 H2, HSQLDB, DERBY, PostgreSQL, MySQL区别/对比图表( 附加翻译) h2数据库
- Mysql 当安装完成后不执行 mysql 和 performance_schema 数据库
- Mysql系列四:数据库分库分表基础理论
- [ 数据库 ] MySQL 入门到放弃(七) --- 索引
- 【MySQL】MySQL数据库结构与操作
- Linux启动/停止/重启Mysql数据库的方法
- Mysql——查看数据库,表占用磁盘大小
- mysql 数据库迁移
- 【mysql我能讲两小时036】为什么需要保证mysql数据库二进制文件写入顺序和innodb层的事务提交顺序一致?