Oracle查询表空间的每日增长量

Oracle查询表空间的每日增长量

—10g和11g

SELECT a.snap_id,
       c.tablespace_name ts_name,
       to_char(to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss'), 'yyyy-mm-dd hh24:mi') rtime,
       round(a.tablespace_size * c.block_size / 1024 / 1024, 2) ts_size_mb,
       round(a.tablespace_usedsize * c.block_size / 1024 / 1024, 2) ts_used_mb,
       round((a.tablespace_size - a.tablespace_usedsize) * c.block_size / 1024 / 1024,
             2) ts_free_mb,
       round(a.tablespace_usedsize / a.tablespace_size * 100, 2) pct_used
  FROM dba_hist_tbspc_space_usage a, 
       (SELECT tablespace_id,
               substr(rtime, 1, 10) rtime,
               max(snap_id) snap_id
          FROM dba_hist_tbspc_space_usage nb
         group by tablespace_id, substr(rtime, 1, 10)) b,
         dba_tablespaces c,
         v$tablespace d
 where a.snap_id = b.snap_id
   and a.tablespace_id = b.tablespace_id
   and a.tablespace_id=d.TS#
   and d.NAME=c.tablespace_name  
	 and  to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') >=sysdate-30
   order by a.tablespace_id,to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') desc;  

–12c

SELECT a.snap_id,
       a.con_id,
       e.name pdbname,
       c.tablespace_name ts_name,
       to_char(to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss'), 'yyyy-mm-dd hh24:mi') rtime,
       round(a.tablespace_size * c.block_size / 1024 / 1024, 2) ts_size_mb,
       round(a.tablespace_usedsize * c.block_size / 1024 / 1024, 2) ts_used_mb,
       round((a.tablespace_size - a.tablespace_usedsize) * c.block_size / 1024 / 1024,
             2) ts_free_mb,
       round(a.tablespace_usedsize / a.tablespace_size * 100, 2) pct_used
  FROM cdb_hist_tbspc_space_usage a, 
       (SELECT tablespace_id,
               nb.con_id,
               substr(rtime, 1, 10) rtime,
               max(snap_id) snap_id
          FROM dba_hist_tbspc_space_usage nb
         group by tablespace_id, nb.con_id,substr(rtime, 1, 10)) b,
         cdb_tablespaces c,
         v$tablespace d,
         V$CONTAINERS e
 where a.snap_id = b.snap_id
   and a.tablespace_id = b.tablespace_id
   and a.con_id=b.con_id
   and a.con_id=c.con_id
   and a.con_id=d.con_id
   and a.con_id=e.con_id
   and a.tablespace_id=d.TS#
   and d.NAME=c.tablespace_name
	 and  to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') >=sysdate-30
   order by a.CON_ID,a.tablespace_id,to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') desc;

–其它

   select u.snap_id,
       to_char(s.begin_interval_time, 'yyyy-mm-dd hh24') begin_time,
       to_char(s.end_interval_time, 'yyyy-mm-dd hh24') end_time,
       t.name,
       round(u.tablespace_size * ts.block_size / 1024 / 1024, 2) ts_size_mb,
       round(u.tablespace_usedsize * ts.block_size / 1024 / 1024, 2) ts_used_mb,
       round((u.tablespace_size - u.tablespace_usedsize) * ts.block_size / 1024 / 1024,
             2) ts_free_mb,
       round(u.tablespace_usedsize / u.tablespace_size * 100, 2) pct_used
  from dba_hist_tbspc_space_usage u,
       v$tablespace               t,
       dba_hist_snapshot          s,
       dba_tablespaces            ts
 where u.tablespace_id = t.ts#
   and u.snap_id = s.snap_id
   and t.name = ts.tablespace_name
   and s.instance_number = 1
   and t.name = 'SYSTEM'
   and s.end_interval_time > sysdate - 7   
     order by snap_id desc;
      
      
     select u.snap_id,
       to_char(s.begin_interval_time, 'yyyy-mm-dd hh24') begin_time,
       to_char(s.end_interval_time, 'yyyy-mm-dd hh24') end_time,
       t.name,
       round(u.tablespace_size * ts.block_size / 1024 / 1024, 2) ts_size_mb,
       round(u.tablespace_usedsize * ts.block_size / 1024 / 1024, 2) ts_used_mb,
       round((u.tablespace_size - u.tablespace_usedsize) * ts.block_size / 1024 / 1024,
             2) ts_free_mb,
       round(u.tablespace_usedsize / u.tablespace_size * 100, 2) pct_used
  from cdb_hist_tbspc_space_usage u,
       v$tablespace               t,
       cdb_hist_snapshot          s,
       cdb_tablespaces            ts
 where u.tablespace_id = t.ts#
   and u.snap_id = s.snap_id
   and t.name = ts.tablespace_name
   and s.instance_number = 1
     and u.CON_ID=t.CON_ID
     and u.CON_ID=s.CON_ID
     and u.CON_ID=ts.CON_ID
   and t.name = 'SYSTEM'
   and s.end_interval_time > sysdate - 7   
   order by snap_id desc;
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值