$ sqlplus eygle/eygle
SQL*Plus: Release 10.1.0.2.0 - Production on Wed Mar 30 08:52:04 2005
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL>select count(*) from t1;
COUNT(*)
----------
9318
2.误删除所有记录
并且提交更改。
SQL>delete from t1;
9318 rows deleted.
SQL>commit;
Commit complete.
SQL>select count(*) from t1;
COUNT(*)
----------
0
3.获得当前SCN
如果能够确切知道删除之前SCN最好,如果不知道,可以进行闪回查询尝试.
SQL>select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
10671006
SQL>select count(*) from t1 as of scn 10671000;
COUNT(*)
----------
0
SQL>select count(*) from t1 as of scn 10670000;
COUNT(*)
----------
9318
我们看到在SCN=10670000时,数据都在。 4.恢复数据.
SQL>insert into t1 select * from t1 as of scn 10670000;
9318 rows created.
SQL>commit;
Commit complete.
SQL>select count(*) from t1;
COUNT(*)
----------
9318
. select * from t_viradsl t //查询t_viradsl中所有的数据,可以看到三条数据
. delete t_viradsl //删除t_viradsl中所有的数据,三条数据消失
. select * from t_viradsl t //无数据。
. insert into t_viradsl select * from t_viradsl as of timestamp to_Date('-- ::', 'yyyy-mm-dd hh:mi:ss') //已将误删除数据插入表中
. select * from t_viradsl t //又会看到三条数据。
我们来分析下第四步,注意这句:
select * from t_viradsl2 as of timestamp to_Date('2011-01-19 15:28:00', 'yyyy-mm-dd hh24:mi:ss')