当前位置:网站首页>How to view the occupied space of a table in MySQL database
How to view the occupied space of a table in MySQL database
2022-06-10 21:51:00 【1024 Q】
Preface
1、 Switch database
2、 View all database capacity sizes
3、 View specified database usage size
4、 View table usage size
5、 View all database capacity sizes
6、 Check the capacity of all databases
7、 View the specified database capacity size
8、 Check the capacity of each table in the specified database
summary
PrefaceCentOS7 install MySQL8 The detailed steps
CentOS7 In the environment MySQL Common commands
stay mysql There is a default data table in information_schema,information_schema This data sheet is saved MySQL Information about all the databases on the server . Such as database name , Table of database , Data type and access right of table column . It's simpler , The machine MySQL Server , What kind of databases are there 、 What are the tables in each database , What is the field type of each table , What permissions do you need to access each database , And so on, information is stored in information_schema Inside the watch , So please don't delete this table .
1、 Switch databaseuse information_schema;2、 View all database capacity sizes selecttable_schema as ' database ',sum(table_rows) as ' Record number ',sum(truncate(data_length/1024/1024, 2)) as ' Data capacity (MB)',sum(truncate(index_length/1024/1024, 2)) as ' Index capacity (MB)'from information_schema.tablesgroup by table_schemaorder by sum(data_length) desc, sum(index_length) desc;3、 View specified database usage size short_video Library name video_info Table name
select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='short_video';4、 View table usage size video_info Table name
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、 View all database capacity sizes selecttable_schema as ' database ',sum(table_rows) as ' Record number ',sum(truncate(data_length/1024/1024, 2)) as ' Data capacity (MB)',sum(truncate(index_length/1024/1024, 2)) as ' Index capacity (MB)'from information_schema.tablesgroup by table_schemaorder by sum(data_length) desc, sum(index_length) desc;6、 Check the capacity of all databases selecttable_schema as ' database ',table_name as ' Table name ',table_rows as ' Record number ',truncate(data_length/1024/1024, 2) as ' Data capacity (MB)',truncate(index_length/1024/1024, 2) as ' Index capacity (MB)'from information_schema.tablesorder by data_length desc, index_length desc;7、 View the specified database capacity size selecttable_schema as ' database ',sum(table_rows) as ' Record number ',sum(truncate(data_length/1024/1024, 2)) as ' Data capacity (MB)',sum(truncate(index_length/1024/1024, 2)) as ' Index capacity (MB)'from information_schema.tableswhere table_schema='short_video';8、 Check the capacity of each table in the specified database selecttable_schema as ' database ',table_name as ' Table name ',table_rows as ' Record number ',truncate(data_length/1024/1024, 2) as ' Data capacity (MB)',truncate(index_length/1024/1024, 2) as ' Index capacity (MB)'from information_schema.tableswhere table_schema='short_video'order by data_length desc, index_length desc; summary This is about MySQL This is the end of the article on how to view the table occupied space in the database , More about MySQL To view the table's occupied space, please search the previous articles of the software development network or continue to browse the following related articles. I hope you can support the software development network in the future !
边栏推荐
- 设计多层PCB板需要注意哪些事项?
- Leetcode advanced road - plus one
- Which city should I go to after I graduate from it? Which position has a high salary? Which companies have good treatment?
- Shell implements SSH login and executes commands
- [qingniaochangping campus of Peking University] the coordinated development of vocational education and general education, will this year's high school entrance examination be easy?
- Rotate menu 2.0
- Naturalspeech model synthetic speech achieves human speech level for the first time in CMOS test
- Leetcode advanced path - delete duplicates in the sorting array
- 目标检测相关概念的理解
- CCF class a conference or journal - regression related papers
猜你喜欢

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

Understanding deep learning attention

As a programmer, is it really that important for the underlying principles?

Factory and strategy mode implementation scheme of coupons

Practical | how to use burp suite for password blasting!

Understanding of related concepts of target detection

Course design of imitation pottery ticket of wechat applet

在模仿学习中进步的智能机器人

标配双安全气囊,价格屠夫长安Lumin 4.89万起售

2022-06-09 RK817 PMU 电池温度检测
随机推荐
视频监控系统存储控件,带宽计算方法
Vissim仿真快速入门
ROS virtual time
Brute force method / adjacency table depth first directed weighted graph undirected weighted graph
Leetcode advanced path - Search insertion location
Redis集群配置
Leetcode advanced path - the first unique character in a string
Cordova Plugin /JPush PhoneGap 极光推送_本地推送_消息推送
Self made table
Brute force method /k integers out of 1~n integers
C language -- 11 branch statement if else
php伪协议实现命令执行详情
[nk] 牛客月賽51 G計算題
LeetCode 进阶之路 - 167.两数之和 II - 输入有序数组
实用 | 如何利用 Burp Suite 进行密码爆破!
Detailed steps and actual records of SQL server2019 installation (available for hands-on test)
The programmed navigation route jumps to the current route (the parameters remain unchanged), and the navigationduplicated warning error will be thrown if it is executed multiple times?
Video monitoring system storage control, bandwidth calculation method
登堂入室之soc开发环境及硬件开发准备
「运维有小邓」自助帐户解锁工具