IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Oracle SQL:统计【Oracle DG】归档日志状态

    Adamhuan发表于 2016-10-22 14:14:46
    love 0

    统计【Oracle DG】日志应用的时间频率的信息
    统计全部:
    select to_char(first_time,’yyyy-mm-dd hh24:mi’) “Date”,ROUND(TO_NUMBER(next_time – first_time) * 24 * 60) “Diff Time [Min]”,applied from v$archived_log;

    按时间统计:
    select to_char(first_time,’yyyy-mm-dd hh24:mi’) “Date”,ROUND(TO_NUMBER(next_time – first_time) * 24 * 60) “Diff Time [Min]”,applied from v$archived_log where to_char(first_time,’yyyy-mm-dd’)=’2016-10-03′;

    统计【Oracle DG】日志应用的数量与状态的信息
    select
    total_tb.date_str “Month”,
    total_tb.count_str “Total Count”,
    result_tb.apply_count “Apply Count”,
    result_tb.noapply_cont “Non-Apply Count”,
    (result_tb.apply_count/total_tb.count_str)*100 “Applied Percent %”
    from
    (
    select
    d_apply_tb.date_str date_str,
    sum(case when d_apply_tb.applied_str=’YES’ then d_apply_tb.count_str else 0 end) apply_count,
    sum(case when d_apply_tb.applied_str=’NO’ then d_apply_tb.count_str else 0 end) noapply_cont
    from
    (select to_char(total.first_time,’yyyy-mm’) date_str,total.applied applied_str,count(*) count_str
    from v$archived_log total
    group by to_char(total.first_time,’yyyy-mm’),total.applied
    order by 1) d_apply_tb
    group by d_apply_tb.date_str
    ) result_tb,
    (select to_char(first_time,’yyyy-mm’) date_str,count(*) count_str from v$archived_log group by to_char(first_time,’yyyy-mm’)) total_tb
    where
    total_tb.date_str = result_tb.date_str
    ;

    ——————————————
    具体的使用,可以参考以下文档:
    http://pan.baidu.com/s/1i5nvbW5
    ——————————————
    Done。



沪ICP备19023445号-2号
友情链接