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

最后修改:2022 年 02 月 27 日
如果觉得我的文章对你有用,请随意赞赏