当前位置:网站首页> MySQL数据库如何查看表占用空间大小
MySQL数据库如何查看表占用空间大小
2022-06-10 20:28:00 【1024问】
前言
1、切换数据库
2、查看所有数据库容量大小
3、查看指定数据库使用大小
4、查看表使用大小
5、查看所有数据库容量大小
6、查看所有数据库各表容量大小
7、查看指定数据库容量大小
8、查看指定数据库各表容量大小
总结
前言CentOS7 安装MySQL8详细步骤
CentOS7 环境下MySQL常用命令
在mysql中有一个默认的数据表information_schema,information_schema这张数据表保存了MySQL服务器所有数据库的信息。如数据库名,数据库的表,表栏的数据类型与访问权限等。再简单点,这台MySQL服务器上,到底有哪些数据库、各个数据库有哪些表,每张表的字段类型是什么,各个数据库要什么权限才能访问,等等信息都保存在information_schema表里面,所以请勿删改此表。
1、切换数据库use information_schema;2、查看所有数据库容量大小selecttable_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.tablesgroup by table_schemaorder 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、查看所有数据库容量大小selecttable_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.tablesgroup by table_schemaorder by sum(data_length) desc, sum(index_length) desc;6、查看所有数据库各表容量大小selecttable_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.tablesorder by data_length desc, index_length desc;7、查看指定数据库容量大小selecttable_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.tableswhere table_schema='short_video';8、查看指定数据库各表容量大小selecttable_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.tableswhere table_schema='short_video'order by data_length desc, index_length desc;总结到此这篇关于MySQL数据库如何查看表占用空间大小的文章就介绍到这了,更多相关MySQL查看表占用空间大小内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!
边栏推荐
- 旋转菜单3.0
- 视频监控系统存储控件,带宽计算方法
- CCF class a conference or journal - regression related papers
- 蛮力法/1~n的全排列 v3 递归
- Monitoring is easy to create a "quasi ecological" pattern and empower Xinchuang to "replace"
- Vissim仿真快速入门
- ^30h5 web worker multithreading
- What should be paid attention to when designing Multilayer PCB?
- Leetcode advanced road - 167 Sum of two numbers II - input ordered array
- 自制Table錶格
猜你喜欢

Signal and system review 1
![[Warning] TIMESTAMP with implicit DEFAULT value is deprecated](/img/e8/53c18a7944d160238f2f1c0f8f04b1.jpg)
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated

Niuke.com: numbers that appear more than half of the times in the array

北大青鸟昌平校区:高中学历可以学UI吗?

软件测试工程师是做什么的?

Attack and defense drill | network security "whistleblower": security monitoring

学IT毕业后该去哪个城市?哪个岗位薪资高?哪些公司待遇好?

入行须知:运维需要懂编程吗?

Quick start to VISSIM simulation

你的公司会选择开发数据中台吗?
随机推荐
shell实现ssh登录并执行命令
Factory and strategy mode implementation scheme of coupons
LeetCode 进阶之路 - 字符串中的第一个唯一字符
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated
LeetCode 进阶之路 - 69.X的平方根
Attack and defense drill | network security "whistleblower": security monitoring
H.264中NALU、RBSP、SODB的关系
在手机上买基金安全吗?会不会被吞本金?
Rotate menu 3.0
Read the source code of micropyton - add the C extension class module (4)
Junior high school graduates who choose secondary vocational schools can also be promoted to institutions of higher learning
Niuke.com: numbers that appear more than half of the times in the array
实用 | 如何利用 Burp Suite 进行密码爆破!
Test APK exception control netlocation attacker development
What should be paid attention to when designing Multilayer PCB?
自制Table表格
C language -- 4 first-time constant
Leetcode advanced road - 69 Square root of X
Practical | how to use burp suite for password blasting!
Redis集群配置