Locations of visitors to this page

Thursday, March 5, 2009

how to get current SCN 如何获得当前系统变更号

how to get current SCN(System Change Number)
如何获得当前系统变更号

9i及以后
select current_scn from v$database;
select dbms_flashback.get_system_change_number from dual;

9i之前
select to_number(m.ksmmmval,'XXXXXXXXXXXXXXXX')
  from x$ksmmem m,
       x$ksmfsv f
 where m.addr = f.ksmfsadr
   and f.ksmfsnam = 'kcsgscn_';


比如:
select current_scn,
       dbms_flashback.get_system_change_number,
       (select to_number(m.ksmmmval,'XXXXXXXXXXXXXXXX')
          from x$ksmmem m,
               x$ksmfsv f
         where m.addr = f.ksmfsadr
           and f.ksmfsnam = 'kcsgscn_')
  from v$database;
SQL> select current_scn,
  2         dbms_flashback.get_system_change_number,
  3         (select to_number(m.ksmmmval,'XXXXXXXXXXXXXXXX')
  4            from x$ksmmem m,
  5                 x$ksmfsv f
  6           where m.addr = f.ksmfsadr
  7             and f.ksmfsnam = 'kcsgscn_')
  8    from v$database;

CURRENT_SCN GET_SYSTEM_CHANGE_NUMBER
----------- ------------------------
(SELECTTO_NUMBER(M.KSMMMVAL,'XXXXXXXXXXXXXXXX')FROMX$KSMMEMM,X$KSMFSVFWHEREM.ADDR=F.KSMFSADRANDF.KSMFSNAM='KCSGSCN_')
---------------------------------------------------------------------------------------------------------------------
    2429997                  2429997
                                                                                                              2429997


SQL>



-fin-

No comments:

Website Analytics

Followers