标签归档:SCN

Oracle DB scn情况查询

–1、查询当前scn情况

select version,
       date_time,
       dbms_flashback.get_system_change_number current_scn,
       indicator
  from (select version,
               to_char(SYSDATE, 'YYYY/MM/DD HH24:MI:SS') DATE_TIME,
               ((((((to_number(to_char(sysdate, 'YYYY')) – 1988) * 12 * 31 * 24 * 60 * 60) +
               ((to_number(to_char(sysdate, 'MM')) – 1) * 31 * 24 * 60 * 60) +
               (((to_number(to_char(sysdate, 'DD')) – 1)) * 24 * 60 * 60) +
               (to_number(to_char(sysdate, 'HH24')) * 60 * 60) +
               (to_number(to_char(sysdate, 'MI')) * 60) +
               (to_number(to_char(sysdate, 'SS')))) * (16 * 1024)) –
               SYS.dbms_flashback.get_system_change_number) /
               (16 * 1024 * 60 * 60 * 24)) indicator
          from v$instance);

–2、查询距离上限天数的历史变化情况

SELECT tim,
       gscn,
       round(rate),
       round((chk16kscn – gscn) / 24 / 3600 / 16 / 1024, 1) "HEADROOM"
  FROM (SELECT tim,
               gscn,
               rate,
               ((((to_number(to_char(tim, 'YYYY')) – 1988) * 12 * 31 * 24 * 60 * 60) +
               ((to_number(to_char(tim, 'MM')) – 1) * 31 * 24 * 60 * 60) +
               (((to_number(to_char(tim, 'DD')) – 1)) * 24 * 60 * 60) +
               (to_number(to_char(tim, 'HH24')) * 60 * 60) +
               (to_number(to_char(tim, 'MI')) * 60) +
               (to_number(to_char(tim, 'SS')))) * (16 * 1024)) chk16kscn
          FROM (SELECT first_time tim,
                       first_change# gscn,
                       ((next_change# – first_change#) /
                       ((next_time – first_time) * 24 * 60 * 60)) rate
                  FROM v$archived_log
                 WHERE (next_time > first_time)))
 ORDER BY 1, 2;

可参考以下链接:

https://www.cnblogs.com/likingzi/p/6420927.html

其他:此脚本来做patch 13498243