首先讲述获得数据库当前scn的方法,这里有两种方式:
(1)通过v$database这个视图:
SYS@orcl 20-OCT-14>select current_scn from v$database;
CURRENT_SCN
-----------
2241165
(2)通过dbms_flashback程序包:
SYS@orcl 20-OCT-14>select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
2241254
从oracle10g开始,提供了时间戳timestamp和scn之间相互转换的函数:
timestamp_to_scn和scn_to_timestamp
(1)通过scn查询相应的时间:
SYS@orcl 20-OCT-14>select
scn_to_timestamp(2241254) time from dual;
TIME
---------------------------------------------------------------------------
20-OCT-14 01.38.55.000000000 AM
(2)通过时间戳查询相应的scn:
SYS@orcl 20-OCT-14>select
timestamp_to_scn(to_timestamp('2014-10-20 01:41:57','yyyy-mm-dd hh24:mi:ss')) scn from dual;
SCN
----------
2241345
通过这两个函数就将scn和timestamp联系到一起了,在oracle10g之前是没有办法将scn和timestamp对应起来的。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29800581/viewspace-1304898/
,如需转载,请注明出处,否则将追究法律责任。