oracle闪回查询

SQL> select * from t1 as of timestamp (systimestamp - interval '2' minute);   ---查询t1表2分钟之前的数据
SQL> select * from t1 as of timestamp (systimestamp - interval '120' second); ---查询t1表120秒之前的数据
SQL> select * from dept as of timestamp (systimestamp - interval '12' hour);  ---查询dept表12小时之前的数据
SQL> select * from dept as of timestamp (systimestamp - interval '12' day);   ---查询dept表12天之前的数据
SQL> select * from cardacct as of timestamp sysdate-2;                              ---查询cardacct表2天之前的数据
SQL> select timestamp_to_scn(to_timestamp('2014-08-24 05:15:22','yyyy-mm-dd hh24:mi:ss')) scn from dual;       --时间和scn之间的转换
       SCN
----------
   1081597

SQL> select scn_to_timestamp(1081597) scn from dual;
SCN
---------------------------------------------------------------------------
24-AUG-14 05.15.21.000000000 AM


闪回查询表t1
SQL> select * from t1;
no rows selected

SQL> select * from t1 as of timestamp (systimestamp - interval '2' minute);

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON


SQL> flashback table t1 to timestamp (systimestamp - interval '2' minute);
Flashback complete.


SQL> select * from t1;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON


SQL> select * from t1 as of timestamp (systimestamp - interval '120' second);
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON


欢迎关注我的微信公众号"IT小Chen",共同学习,共同成长!!!



请使用浏览器的分享功能分享到微信等