当前位置:网站首页>查看数据库数据量大小,占用磁盘大小
查看数据库数据量大小,占用磁盘大小
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
边栏推荐
- MySQL基本操作和基于MySQL基本操作的综合实例项目
- Arduino hardware programming introduction to language learning
- [C Language Brush Questions] Three Questions for Getting Started with Pointers | String Length, String Copy, Two Number Swap
- cpolar应用实例之多设备数据采集
- 谁抢走了华大基因的生意?
- NoSQL之redis缓存雪崩、穿透、击穿概念解决办法
- 恒驰5真的没大卖
- redis summary_distributed cache
- Mysql应用安装后找不到my.ini文件
- Five speakers: seventy genius_platform software platform development 】 【 turn YUY2 RGB24 implementation source code
猜你喜欢
随机推荐
MySQL基本语法
npm install 报错问题解决合集
golang源码分析(3):thrift
谁抢走了华大基因的生意?
恒驰5真的没大卖
小程序毕设作品之微信体育馆预约小程序毕业设计成品(8)毕业设计论文模板
Mini Program Graduation Works WeChat Gymnasium Reservation Mini Program Graduation Design Finished Product (8) Graduation Design Thesis Template
golang源码分析(6):sync.Mutex sync.RWMutex
FP6606CLP5 SOP-8 USB Type-C和PD充电控制器
每日优鲜倒了,叮咚买菜的春天在哪?
织梦提示信息提示框美化
【21天学习挑战赛学习打卡】顺序查找
分布式 | dble 启动的时候做了什么之配置检测
记一次 .NET 某工控自动化控制系统 卡死分析
再获权威认证!马上消费安逸花APP通过中国信通院“金融APP人脸识别安全能力评测”
golang源码分析(9)调度
DeepMind 首席科学家 Oriol Vinyals 最新访谈:通用 AI 的未来是强交互式元学习
研发运营一体化(DevOps)能力成熟度模型
Real-time data warehouse architecture evolution and selection
golang源码分析(12)martini源码分析