scn和data、TIMESTAMP转换

来源:互联网 发布:数据及时准确的重要性 编辑:程序博客网 时间:2024/05/23 11:47

首先通过dbms_flashback.get_system_change_number 可以获得系统当前的SCN值:

SQL> select dbms_flashback.get_system_change_number scn from dual;
 
       SCN
----------
   3298568


1、通过scn_to_timestamp函数可以将SCN转换为时间戳:

SQL> select scn_to_timestamp(3298568) scn from dual;
 
SCN
--------------------------------------------------------------------------------
16-12月-11 11.51.18.000000000 上午
 

2、把data转换为TIMESTAMP

SQL> select TO_TIMESTAMP_TZ('2011-3-9 17:51:23','YYYY-MM-DD HH24:MI:SS') from dual;
 
TO_TIMESTAMP_TZ('2011-3-917:51
--------------------------------------------------------------------------------
09-3月 -11 05.51.23.000000000 下午 +08:00


3、补充一个,TIMESTAMP转换成date

select SAMPLE_TIME+0 from v$active_session_history;

select cast(SAMPLE_TIME as date) from v$active_session_history;


4、再通过timestamp_to_scn可以将时间戳转换为SCN:

SQL> select timestamp_to_scn(TO_TIMESTAMP_TZ('2011-12-15 17:51:23','YYYY-MM-DD HH24:MI:SS')) from dual;
 
TIMESTAMP_TO_SCN(TO_TIMESTAMP_
------------------------------
                       3245939




原创粉丝点击