加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

精心总结--Oracle查询表空间的每日增长量和历史情况统计脚本

发布时间:2019-10-15 11:24:50 所属栏目:MySql教程 来源:波波说运维
导读:副标题#e# 今天主要总结一下Oracle表空间每日增长和历史情况统计的一些脚本,仅供参考。 11g统计表空间的每日增长量 SELECTa.snap_id, c.tablespace_namets_name, to_char(to_date(a.rtime,'mm/dd/yyyyhh24:mi:ss'), 'yyyy-mm-ddhh24:mi')rtime, round(a.ta

不含undo和temp:

  1. with tmp as ( 
  2. select rtime,sum(tablespace_usedsize_kb) tablespace_usedsize_kb, sum(tablespace_size_kb) tablespace_size_kb  
  3. from (select rtime, e.tablespace_id, (e.tablespace_usedsize)*(f.block_size)/1024 tablespace_usedsize_kb,  
  4. (e.tablespace_size)*(f.block_size)/1024 tablespace_size_kb from dba_hist_tbspc_space_usage e, dba_tablespaces f, v$tablespace g 
  5.  where e.tablespace_id = g.TS# and f.tablespace_name = g.NAME and f.contents not in ('TEMPORARY','UNDO')) group by rtime)  
  6. select tmp.rtime, tablespace_usedsize_kb, tablespace_size_kb,(tablespace_usedsize_kb - LAG(tablespace_usedsize_kb, 1, NULL) 
  7.  OVER(ORDER BY tmp.rtime)) AS DIFF_KB from tmp, (select max(rtime) rtime from tmp group by substr(rtime, 1, 10)) t2 
  8.  where t2.rtime = tmp.rtime; 

含undo和temp:

  1. with tmp as ( 
  2. select min(rtime) rtime, sum(tablespace_usedsize_kb) tablespace_usedsize_kb, sum(tablespace_size_kb) tablespace_size_kb  
  3. from (select rtime, e.tablespace_id, (e.tablespace_usedsize) * (f.block_size) / 1024 tablespace_usedsize_kb,  
  4. (e.tablespace_size) * (f.block_size) / 1024 tablespace_size_kb from dba_hist_tbspc_space_usage e, dba_tablespaces f, v$tablespace g  
  5. where e.tablespace_id = g.TS# and f.tablespace_name = g.NAME) group by rtime)  
  6. select tmp.rtime, tablespace_usedsize_kb, tablespace_size_kb, (tablespace_usedsize_kb-LAG(tablespace_usedsize_kb, 1, NULL) 
  7. OVER(ORDER BY tmp.rtime)) AS DIFF_KB from tmp, (select min(rtime) rtime from tmp group by substr(rtime, 1, 10)) t2  
  8. where t2.rtime = tmp.rtime 

精心总结--Oracle查询表空间的每日增长量和历史情况统计脚本

精心总结--Oracle查询表空间的每日增长量和历史情况统计脚本

列出相关段对象在 快照时间内的使用空间的历史变化信息

  1. select obj.owner, 
  2.  obj.object_name, 
  3.  to_char(sn.BEGIN_INTERVAL_TIME, 'RRRR-MON-DD') start_day, 
  4.  sum(a.db_block_changes_delta) block_increase 
  5.  from dba_hist_seg_stat a, dba_hist_snapshot sn, dba_objects obj 
  6.  where sn.snap_id = a.snap_id 
  7.  and obj.object_id = a.obj# 
  8.  and obj.owner not in ('SYS', 'SYSTEM') 
  9.  and end_interval_time between to_timestamp('01-OCT-2019', 'DD-MON-RRRR') and 
  10.  to_timestamp('09-OCT-2019', 'DD-MON-RRRR') 
  11.  group by obj.owner, 
  12.  obj.object_name, 
  13.  to_char(sn.BEGIN_INTERVAL_TIME, 'RRRR-MON-DD') 
  14.  order by obj.owner, obj.object_name; 

精心总结--Oracle查询表空间的每日增长量和历史情况统计脚本

【编辑推荐】

  1. 10月数据库排行:Microsoft SQL Server 分数增加最多
  2. 分享一份大佬的MySQL数据库设计规范,值得收藏
  3. 传统数据库不适合现代企业架构了?
  4. MySQL数据库基础篇之入门基础命令
  5. MySQL数据库入门多实例配置
【责任编辑:赵宁宁 TEL:(010)68476606】
点赞 0

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读