Oracle timestamp & SCN

1, systimestamp与sysdate
SQL>select systimestamp - interval '1' hour from dual;

SYSTIMESTAMP-INTERVAL'1'HOUR
---------------------------------------------------------------------------
23-JUN-12 09.59.47.706252000 AM +08:00

SQL>select sysdate - interval '1' hour from dual;
SYSDATE-INTERVAL'1'
-------------------
2012-06-23 09:59:54

2, smon_scn_time,timestamp_to_scn,scn_to_timestamp,函数转换是基于smon_scn_time表的记录.
SQL>select time_dp,scn from smon_scn_time where time_dp > to_timestamp('2012-06-20','yyyy-mm-dd') order by 1;

SQL>select timestamp_to_scn(to_timestamp('2012-06-23 10:21:00','yyyy-mm-dd hh24:mi:ss')) from dual;
TIMESTAMP_TO_SCN(TO_TIMESTAMP('2012-06-2310:21:00','YYYY-MM-DDHH24:MI:SS'))
---------------------------------------------------------------------------
                                                                    7448869

SQL>select scn_to_timestamp(7413120) from dual;
SCN_TO_TIMESTAMP(7413120)
---------------------------------------------------------------------------
20-JUN-12 08.50.57.000000000 PM

3, 例子,删除了数据,做flashback查询.
23-JUN-12 HR @ itods>delete join3 where id=3;
23-JUN-12 HR @ itods>select timestamp_to_scn(to_timestamp('2012-06-23 17:43:19','yyyy-mm-dd hh24:mi:ss')) from dual;
TIMESTAMP_TO_SCN(TO_TIMESTAMP('2012-06-2317:43:19','YYYY-MM-DDHH24:MI:SS'))
---------------------------------------------------------------------------
                                                                    5437878
23-JUN-12 HR @ itods>select scn_to_timestamp(5437878) from dual;
SCN_TO_TIMESTAMP(5437878)
---------------------------------------------------------------------------
23-JUN-12 05.43.17.000000000 PM
23-JUN-12 HR @ itods>select * from join3 as of timestamp to_timestamp('2012-06-23 17:43:19','yyyy-mm-dd hh24:mi:ss');

        ID CONTENT
---------- --------------------
         1 txt1
         2 txt2
         3 txt3

23-JUN-12 HR @ itods>select * from join3 as of timestamp to_timestamp('2012-06-23 17:43:20','yyyy-mm-dd hh24:mi:ss');

        ID CONTENT
---------- --------------------
         1 txt1
         2 txt2
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值