博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
查询表空间的总大小,剩余表空间,已用空间,表占用大小,某天占用的大小...
阅读量:7266 次
发布时间:2019-06-29

本文共 1647 字,大约阅读时间需要 5 分钟。

引用 :http://blog.csdn.net/cosio/article/details/3978747  , https://zhidao.baidu.com/question/628524115699308364.html

block 块

extent 区
segment 段

--增加USERS表空间500M空间

alter tablespace USERS add datafile '/data01/oradata/bidb96/USER_test30.bdf' size 500M;
select file_name , tablespace_name, t.* from dba_data_files t where tablespace_name = 'USERS' order by file_id;

--每个表占用的空间
select segment_name,sum(bytes )/1024/1024/1024 GB
from user_segments --where segment_name ='TR_GOV_WJ_XNH_D'
group by segment_name ;

--20190530这天TW层占用的空间
select count(distinct segment_name) tb_cnt,sum(bytes)/(1024*1024*1024) GB
from user_segments t
where partition_name='P_20190530'
and segment_name like 'TW%';

----查看剩余表空间  汇总

SELECT t1 表空间,z 总表空间,z-s 已用表空间,s 剩余表空间,ROUND((z-s)/z*100,2) "使用率%"
From (Select tablespace_name t1,Sum(bytes)/(1024*1024*1024) s
 From DBA_FREE_SPACE Group by tablespace_name),
 (Select tablespace_name t2,Sum(bytes)/(1024*1024*1024) z
 From DBA_DATA_FILES Group by tablespace_name) Where t1=t2;

---表空间总共的空间  
select tablespace_name,sum(bytes)/(1024*1024*1024) GB from dba_data_files
group by tablespace_name
;
--表空间剩余空间
select tablespace_name,sum(bytes)/(1024*1024*1024) GB from user_free_space
group by tablespace_name
;
--表空间占用的空间 表空间所有对象的物理占用(表,分区,索引等) 这个和DBA_DATA_FILES的大小才一样
select tablespace_name,sum(bytes)/(1024*1024*1024) GB from user_segments
group by tablespace_name
;

----表实际使用大小  这个大小相加必定<DBA_DATA_FILES的大小,因为只有表 , 这个貌似没有及时更新

select table_name,(num_rows * avg_row_len )/(1024*1024*1024) 该表大小GB
from user_tables 
where table_name = '表名大写'--672699条数据 0.306965947151184GB
order by 2 desc

转载于:https://www.cnblogs.com/jiangqingfeng/p/10956749.html

你可能感兴趣的文章
基于java网络聊天室--服务器端
查看>>
mysql从入门到放弃-入门知识介绍
查看>>
[SDOI2010]大陆争霸
查看>>
UVA 12520 Square Garden
查看>>
新的开始
查看>>
Effective C++ 阅读笔记(一)透彻了解inline以及降低编译依存关系
查看>>
C# Hashtable vs Dictionary 学习笔记
查看>>
angular 按需加载
查看>>
关于django的操作(四)
查看>>
在CListView中添加点击右键消息响应函数!
查看>>
微信跳一跳
查看>>
location对象的使用
查看>>
php搭建redis扩展安装及配置
查看>>
DOS批处理高级教程:第四章 批处理中的变量
查看>>
【机器学习】多项式回归
查看>>
Cube的高级设置
查看>>
golang笔记——命令
查看>>
return在try...except...finally...中的表现
查看>>
RabbitMQ入门教程
查看>>
树莓派使用Samba进行局域网共享
查看>>