We have already database in flashback mode. Let's see what option in gives us:
1. See object in a past:
SQL> select count(*) from t1;
COUNT(*)
----------
132027
SQL> select count(*) from t1 as of timestamp to_timestamp('2008-11-26 07:00:00','YYYY-MM-DD HH24:MI:SS');
COUNT(*)
----------
40001
Alternatively you can use SCN:
SQL> SELECT SCN,
2 to_char(TIME_DP, 'YYYY-MM-DD HH24:MI:SS') TIME_DP
3 from sys.SMON_SCN_TIME
4 where to_char(TIME_DP,'YYYY-MM-DD HH24') = to_char(sysdate-1,'YYYY-MM-DD HH24')
5 order by SCN_BAS;
SCN TIME_DP
-------------- ------------------------------
8704635105759 2008-11-26 07:00:29
8704635105915 2008-11-26 07:05:34
8704635106215 2008-11-26 07:10:31
8704635106316 2008-11-26 07:15:34
8704635106420 2008-11-26 07:20:32
8704635106521 2008-11-26 07:25:35
8704635106631 2008-11-26 07:30:32
8704635106735 2008-11-26 07:35:35
8704635106839 2008-11-26 07:40:32
8704635106940 2008-11-26 07:45:35
8704635107058 2008-11-26 07:50:32
8704635107159 2008-11-26 07:55:35
SQL> select count(*) from t1 as of scn 8704635105759;
COUNT(*)
----------
40001
2. Turn database to some point in time:
SQL> EXECUTE dbms_Flashback.Enable_At_Time(to_date('2008-11-26 07:00:00','YYYY-MM-DD HH24:MI:SS'));
PL/SQL procedure successfully completed.
SQL> select count(*) from t1;
COUNT(*)
----------
40001
SQL> EXECUTE dbms_Flashback.disable;
PL/SQL procedure successfully completed.
SQL> select count(*) from t1;
COUNT(*)
----------
132027
1. See object in a past:
SQL> select count(*) from t1;
COUNT(*)
----------
132027
SQL> select count(*) from t1 as of timestamp to_timestamp('2008-11-26 07:00:00','YYYY-MM-DD HH24:MI:SS');
COUNT(*)
----------
40001
Alternatively you can use SCN:
SQL> SELECT SCN,
2 to_char(TIME_DP, 'YYYY-MM-DD HH24:MI:SS') TIME_DP
3 from sys.SMON_SCN_TIME
4 where to_char(TIME_DP,'YYYY-MM-DD HH24') = to_char(sysdate-1,'YYYY-MM-DD HH24')
5 order by SCN_BAS;
SCN TIME_DP
-------------- ------------------------------
8704635105759 2008-11-26 07:00:29
8704635105915 2008-11-26 07:05:34
8704635106215 2008-11-26 07:10:31
8704635106316 2008-11-26 07:15:34
8704635106420 2008-11-26 07:20:32
8704635106521 2008-11-26 07:25:35
8704635106631 2008-11-26 07:30:32
8704635106735 2008-11-26 07:35:35
8704635106839 2008-11-26 07:40:32
8704635106940 2008-11-26 07:45:35
8704635107058 2008-11-26 07:50:32
8704635107159 2008-11-26 07:55:35
SQL> select count(*) from t1 as of scn 8704635105759;
COUNT(*)
----------
40001
2. Turn database to some point in time:
SQL> EXECUTE dbms_Flashback.Enable_At_Time(to_date('2008-11-26 07:00:00','YYYY-MM-DD HH24:MI:SS'));
PL/SQL procedure successfully completed.
SQL> select count(*) from t1;
COUNT(*)
----------
40001
SQL> EXECUTE dbms_Flashback.disable;
PL/SQL procedure successfully completed.
SQL> select count(*) from t1;
COUNT(*)
----------
132027
No comments:
Post a Comment