首页 热点 业界 科技快讯 数码 电子消费 通信 前沿动态 电商

MySQL数据库如何查看表占用空间大小

2022-06-11 05:22:12 来源 : 软件开发网

目录

前言

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查看表占用空间大小内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!

标签: 占用空间 查看表使用

相关文章

最近更新
观焦点:超萌相机 2023-03-01 12:29:37
海南百货网 2023-03-01 12:13:44
焦点热讯:宜点充 2023-02-28 10:10:16
天天关注:小铺CEO 2023-02-28 10:07:13
【世界聚看点】KaFit 2023-02-28 09:31:37
葱天下 2023-02-28 09:17:03
渔界竞钓 2023-02-28 08:15:29
焦点快看:鲸奇视频 2023-02-28 06:30:37
环球热议:萝小逗 2023-02-27 23:25:49
简讯:小码公交 2023-02-27 23:16:12
彼岸花 2023-02-27 22:32:52
时时夺宝 2023-02-27 21:37:50
天天动态:袜之源 2023-02-27 21:29:50
天天资讯:AI空气 2023-02-27 20:19:46
世界时讯:绘读 2023-02-27 20:19:41
看点:一元得购 2023-02-27 19:26:28