SQL> CREATE TABLE test_fb_table (
2 ID int,
3 VALVARCHAR2(10)
4);
Table created.
SQL> INSERT INTO test_fb_tableVALUES (1, 'TEST');
1 row created.
SQL> commit;
Commit complete.
假如数据被错误的删除/更新
需要检索某个时间点上,表原有的数据。
SQL> SELECT TO_CHAR(sysdate, 'yyyy-mm-dd hh24:mi:ss') FROM dual;
TO_CHAR(SYSDATE,'YYYY-MM-DDHH24:MI:SS'
--------------------------------------
2010-11-07 13:01:37
这里删除掉数据。
SQL> delete from test_fb_table;
1 row deleted.
SQL> commit;
Commit complete.
确认数据已经被删除。
SQL> select * from test_fb_table;
no rows selected
方法一:
这里检索出,指定时间点上,指定表的数据情况。
SQL> select * from test_fb_table
AS OF TIMESTAMP TO_TIMESTAMP('2010-11-07 13:01:37',
'yyyy-mm-dd hh24:mi:ss');
ID VAL
---------- --------------------
1 TEST
方法二:
使用 dbms_flashback下面的方法来切换。
SQL> conn system
Enter password:
Connected.
SQL> select * from hr.test_fb_table;
no rows selected
SQL> execute dbms_flashback.enable_at_time(-
> TO_TIMESTAMP('2010-11-07 13:01:37','yyyy-mm-dd hh24:mi:ss'));
PL/SQL procedure successfully completed.
SQL> select * from hr.test_fb_table;
ID VAL
---------- --------------------
1 TEST
SQL> execute dbms_flashback.disable;
PL/SQL procedure successfully completed.
SQL> select * from hr.test_fb_table;
no rows selected