当前位置:网站首页>查看数据库数据量大小,占用磁盘大小
查看数据库数据量大小,占用磁盘大小
2022-08-02 17:33:00 【Direct_】
文章目录
查看数据库数据量大小,占用磁盘大小
本次测试使用
mysql
数据库
数据库名demo
1. 查看现有数据库
show databases;
2. 进入information_schema 数据库(存放了其他的数据库的信息)
use information_schema;
3. 查看 information_schema 数据库表信息
select * from information_schema.tables;
4. 查询所有数据的总大小:
select concat(round(sum(data_length/1024/1024),2),'MB') as data from information_schema.tables;
5. 查看实例下所有数据库的空间占用情况,并按从大小排序
select table_schema ,concat(round(sum(data_length/1024/1024),2),'MB') as data from information_schema.tables where table_schema like '%%' group by table_schema order by data desc;
6.查看指定数据库的大小:
select concat(round(sum(data_length/1024/1024),2),'MB') as data from information_schema.tables where table_schema='demo' ;
7. 查看指定数据库下的所有表的空间占用情况,并按从大到小排序
select table_name,round(sum(data_length/1024/1024),2) as size from information_schema.tables where table_schema='demo' group by table_name order by size desc;
8. 查看指定数据库的某个表的大小
select concat(round(sum(data_length/1024/1024),2),'MB') as data from information_schema.tables where table_schema='demo' and table_name='t_student' ;
其他
select table_schema ,
round(sum(data_length/1024/1024),2) as data_length ,
round(sum(DATA_FREE/1024/1024),2) as data_free ,
round(sum(INDEX_LENGTH/1024/1024),2) as INDEX_LENGTH from information_schema.tables where table_schema='demo' group by table_schema order by data_length;
select
TABLE_SCHEMA
,sum(DATA_LENGTH)/1024/1024/1024 as size_DATA_LENGTH_g
,sum(INDEX_LENGTH)/1024/1024/1024 as size_INDEX_LENGTH_g
,sum(DATA_FREE)/1024/1024/1024 as size_DATA_FREE_g
,sum((DATA_LENGTH+INDEX_LENGTH+DATA_FREE))/1024/1024/1024 as size_g
from information_schema.tables
where table_type = 'BASE TABLE'
group by TABLE_SCHEMA
order by size_DATA_FREE_g
;
select
TABLE_NAME
,sum(DATA_LENGTH)/1024/1024/1024 as size_DATA_LENGTH_g
,sum(INDEX_LENGTH)/1024/1024/1024 as size_INDEX_LENGTH_g
,sum(DATA_FREE)/1024/1024/1024 as size_DATA_FREE_g
,sum((DATA_LENGTH+INDEX_LENGTH+DATA_FREE))/1024/1024/1024 as size_g
from information_schema.tables
where table_type = 'BASE TABLE'
and table_schema = 'db_name'
– and TABLE_NAME = 'table_name'
group by TABLE_NAME
order by size_g desc
limit 20
边栏推荐
猜你喜欢
全面认识二极管,一篇文章就够了
Five speakers: seventy genius_platform software platform development 】 【 turn YUY2 RGB24 implementation source code
Inconsistency between oracle and mysql statement results
What is the difference between erp system and wms system
Continuous integration (4) Jenkins configuration alarm mechanism
DeepMind 首席科学家 Oriol Vinyals 最新访谈:通用 AI 的未来是强交互式元学习
搭建属于自己的知识库(Wikijs)
每日优鲜倒了,叮咚买菜的春天在哪?
灵动微电子发布低功耗 MM32L0130 系列 MCU 产品
MySQL表的约束
随机推荐
mui中使用多级选择器实现省市区联动
[C Language Brush Questions] Three Questions for Getting Started with Pointers | String Length, String Copy, Two Number Swap
Mini Program Graduation Works WeChat Gymnasium Reservation Mini Program Graduation Design Finished Product (8) Graduation Design Thesis Template
【案例】2D变换-旋转动画
「全球数字经济大会」登陆 N 世界,融云提供通信云服务支持
嵌入式Qt-做一个秒表
Wechat Gymnasium Appointment Mini Program Graduation Design Finished Work (5) Task Book
golang源码分析(13)gorpc源码分析
C语言中的一系列操作符
织梦自定义表单添加全选和全不选功能按钮
php弱类型-攻防世界lottery
npm install 编译时报“Cannot read properties of null (reading ‘pickAlgorithm‘)“
动力电池扩产潮,宁德时代遭围剿
MySQL常见函数
Inconsistency between oracle and mysql statement results
SQL Statement Basics
golang源码分析(6):sync.Mutex sync.RWMutex
golang 计算器实现
npm install报错Fix the upstream dependency conflict, or retry
解决多版本jar包冲突问题