mysql查询表占用空间大小_oracle查看表空间大小
2023-06-13 09:13:42 时间
大家好,又见面了,我是你们的朋友全栈君。
文章目录
前言
在mysql中有一个默认的数据表information_schema
,information_schema这张数据表保存了MySQL服务器所有数据库的信息。如数据库名,数据库的表,表栏的数据类型与访问权限等。再简单点,这台MySQL服务器上,到底有哪些数据库、各个数据库有哪些表,每张表的字段类型是什么,各个数据库要什么权限才能访问,等等信息都保存在information_schema
表里面,所以请勿删改此表。
1、切换数据库
use information_schema;
2、查看所有数据库容量大小
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;
3、查看指定数据库使用大小
short_video
库名 video_info
表名
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='short_video';
4、查看表使用大小
video_info
表名
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='short_video' and table_name='video_info';
5、查看所有数据库容量大小
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;
6、查看所有数据库各表容量大小
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;
7、查看指定数据库容量大小
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='short_video';
8、查看指定数据库各表容量大小
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='short_video'
order by data_length desc, index_length desc;
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/197292.html原文链接:https://javaforall.cn
相关文章
- 缩短如何缩短Oracle运行时间(oracle运行时间)
- 使用Oracle表值函数提高数据库性能(oracle表值函数)
- 结构MySQL存储实现树形结构算法(mysql存储树形)
- 循环MySQL中使用while循环编写查询语句(mysql的while)
- 数据库 从cmd中删除MySQL数据库.(cmd删除mysql)
- MySQL多表查询笔试:挑战你的SQL技能(mysql多表查询笔试题)
- MySQL数据库查询:获取精准结果的基础(mysql查询值)
- MySQL的关联查询:两张表的合并查询(mysql两个表关联查询)
- MySQL 数据库建表常用数据类型概述(mysql建表数据类型)
- MySQL中的范围查询与索引优化(mysql范围查询索引)
- 提升数据库效率:优化Oracle索引技巧深入探讨Oracle索引调优,提高数据库效率Oracle索引优化策略,助力高效查询与数据分析掌握Oracle索引优化技巧,加速数据库访问速度精通Oracle索引优化,实现高效稳定的数据库运维(oracle索引效率)
- MySQL空间索引:玩转数据查询(mysql 空间索引使用)
- 为:áo ró kèOracle:开启一片可能性的大门(oracle拼音)
- Oracle关联查询特有写法指南(oracle关联特有写法)
- 深度解析MySQL内关联查询的奥秘(mysql中内关联)
- Oracle临时表缓存极大优化数据查询性能(oracle 临时表缓存)
- Oracle数据库中相加函数的应用(oracle中相加函数)
- Oracle码表查看必看攻略(oracle中的码表查看)
- MySQL调整时区问题实现正确的下一天查询(mysql 下一天)
- 探索Oracle数据库中的排序查询(oracle中的排序查询)
- 利用Oracle中的IN语句优化查询效率(oracle中的in语句)
- Oracle免费使用时限多久(oracle不买能用多久)
- Oracle R11安装一步一步走(oracle r11安装)
- 使用Oracle AWK实现高效数据处理(oracle awk)