码迷,mamicode.com
首页 > 其他好文 > 详细

查询表空间使用率(自动扩展的也能查噢)

时间:2019-01-27 10:48:02      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:分享   pac   xtend   .com   dba   color   sed   select   run   

col tablespace_name for a40
col CUR_PCT for a10
col EXT_PCT for a10
select 
tablespace,
current_used_mb,
total_mb,
can_extend_mb,
trunc(current_used_mb/total_mb*100,2)||% cur_pct,
trunc(current_used_mb/can_extend_mb*100,2)||% ext_pct,
count_file
from
(select
a.tablespace_name tablespace,
trunc((b.total-a.free)/1024/1024,2) current_used_mb,
trunc(b.total/1024/1024,2) total_mb,
trunc(b.extent_total/1024/1024) can_extend_mb,
b.count_file count_file
from
(select 
tablespace_name,
sum(bytes) free
from dba_free_space
group by tablespace_name) a,  
(select tablespace_name,                                         
sum(nvl(bytes,0)) total,                       
sum(decode(maxbytes,0,bytes,maxbytes)) extent_total,       
count(file_name) count_file                                    
from dba_data_files                                           
group by tablespace_name) b
where a.tablespace_name=b.tablespace_name); 

技术分享图片

 

查询表空间使用率(自动扩展的也能查噢)

标签:分享   pac   xtend   .com   dba   color   sed   select   run   

原文地址:https://www.cnblogs.com/nathon-wang/p/10325442.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!