加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (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
副标题[/!--empirenews.page--]

今天主要总结一下Oracle表空间每日增长和历史情况统计的一些脚本,仅供参考。

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

11g统计表空间的每日增长量

  1. SELECT a.snap_id, 
  2.  c.tablespace_name ts_name, 
  3.  to_char(to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss'), 
  4.  'yyyy-mm-dd hh24:mi') rtime, 
  5.  round(a.tablespace_size * c.block_size / 1024 / 1024, 2) ts_size_mb, 
  6.  round(a.tablespace_usedsize * c.block_size / 1024 / 1024, 2) ts_used_mb, 
  7.  round((a.tablespace_size - a.tablespace_usedsize) * c.block_size / 1024 / 1024, 
  8.  2) ts_free_mb, 
  9.  round(a.tablespace_usedsize / a.tablespace_size * 100, 2) pct_used 
  10.  FROM dba_hist_tbspc_space_usage a, 
  11.  (SELECT tablespace_id, 
  12.  substr(rtime, 1, 10) rtime, 
  13.  max(snap_id) snap_id 
  14.  FROM dba_hist_tbspc_space_usage nb 
  15.  group by tablespace_id, substr(rtime, 1, 10)) b, 
  16.  dba_tablespaces c, 
  17.  v$tablespace d 
  18.  where a.snap_id = b.snap_id 
  19.  and a.tablespace_id = b.tablespace_id 
  20.  and a.tablespace_id = d.TS# 
  21.  and d.NAME = c.tablespace_name 
  22.  and to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') >= sysdate - 30 
  23.  order by a.tablespace_id, to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') desc; 

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

12c统计表空间的每日增长量

  1. SELECT a.snap_id, 
  2.  a.con_id, 
  3.  e.name pdbname, 
  4.  c.tablespace_name ts_name, 
  5.  to_char(to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss'), 'yyyy-mm-dd hh24:mi') rtime, 
  6.  round(a.tablespace_size * c.block_size / 1024 / 1024, 2) ts_size_mb, 
  7.  round(a.tablespace_usedsize * c.block_size / 1024 / 1024, 2) ts_used_mb, 
  8.  round((a.tablespace_size - a.tablespace_usedsize) * c.block_size / 1024 / 1024, 
  9.  2) ts_free_mb, 
  10.  round(a.tablespace_usedsize / a.tablespace_size * 100, 2) pct_used 
  11.  FROM cdb_hist_tbspc_space_usage a,  
  12.  (SELECT tablespace_id, 
  13.  nb.con_id, 
  14.  substr(rtime, 1, 10) rtime, 
  15.  max(snap_id) snap_id 
  16.  FROM dba_hist_tbspc_space_usage nb 
  17.  group by tablespace_id, nb.con_id,substr(rtime, 1, 10)) b, 
  18.  cdb_tablespaces c, 
  19.  v$tablespace d, 
  20.  V$CONTAINERS e 
  21.  where a.snap_id = b.snap_id 
  22.  and a.tablespace_id = b.tablespace_id 
  23.  and a.con_id=b.con_id 
  24.  and a.con_id=c.con_id 
  25.  and a.con_id=d.con_id 
  26.  and a.con_id=e.con_id 
  27.  and a.tablespace_id=d.TS# 
  28.  and d.NAME=c.tablespace_name 
  29.  and to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') >=sysdate-30 
  30.  order by a.CON_ID,a.tablespace_id,to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') desc; 

估算oracle 数据库,数据库对象历史增长情况

最近七天数据库的增长情况,这个只是一个估算值。

  1. select sum(space_used_total) / 1024 / 1024 / 1024 "last 7 days db increase - G" 
  2.  from dba_hist_seg_stat s, dba_hist_seg_stat_obj o, dba_hist_snapshot sn 
  3.  where s.obj# = o.obj# 
  4.  and ssn.snap_id = s.snap_id 
  5.  and begin_interval_time > sysdate - 8 
  6.  order by begin_interval_time 

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

查看数据库历史增长情况

此处是通过计算数据库所有表空间的历史增长情况来计算数据库历史情况。

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

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

热点阅读