SCN 時間戳記的相互轉換,scn相互轉換

來源:互聯網
上載者:User

SCN 時間戳記的相互轉換,scn相互轉換
SQL> select * from v$version where rownum=1;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
SQL> !cat /etc/issue
Enterprise Linux Enterprise Linux Server release 5.5 (Carthage)
Kernel \r on an \m

oracle 10g提供了兩個新的函數對於scn和時間戳記進行相互轉換,這兩個函數是scn_to_timestamp,timestamp_to_scn,這兩者的相互轉換,給管理者帶來極大的便利。
在10g之前oracle是沒有辦法通過函數得到時間和scn的對應關係(一般通過logmnr分析日誌獲得,但是這種轉換是依賴於資料庫內部的資料記錄,對於久遠的scn不能轉換。
獲得當前資料庫scn:

SQL> select CURRENT_SCN  from v$database;


CURRENT_SCN
-----------
    9501880

SQL>  select dbms_flashback.get_system_change_number from dual;


GET_SYSTEM_CHANGE_NUMBER
------------------------
                 9502397



SQL> select  systimestamp from dual;


SYSTIMESTAMP
---------------------------------------------------------------------------
09-6月 -15 01.30.16.101027 下午 +08:00

SQL> select scn_to_timestamp( 9501954) from dual;


SCN_TO_TIMESTAMP(9501954)
---------------------------------------------------------------------------
09-6月 -15 01.30.15.000000000 下午


SQL> select timestamp_to_scn(scn_to_timestamp( 9501954)) from dual;


TIMESTAMP_TO_SCN(SCN_TO_TIMESTAMP(9501954))
-------------------------------------------
                                    9501952


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.