因为一时手贱,生产上的数据被我给delete掉了。
用的是delete语句,然后很迅速的还给commit了
下面这两个语句:
ALTER TABLE tablename ENABLE row movement ;
flashback table tablename to timestamp to_timestamp('2012-09-13 13:00:00','yyyy-mm-dd hh24:mi:ss');
记得大概是两点半左右运行的delete---commit;
具体执行流程我们可从以下几个示例图中体会; 1.原表记录
$ 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
1. select * from t_viradsl2 t //查询t_viradsl2中所有的数据,可以看到三条数据
2. delete t_viradsl2 //删除t_viradsl2中所有的数据,三条数据消失
3. select * from t_viradsl2 t //无数据。
4. insert into t_viradsl2 select * from t_viradsl2 as of timestamp to_Date('2011-01-19 15:28:00', 'yyyy-mm-dd hh24:mi:ss') //已将误删除数据插入表中
5. select * from t_viradsl2 t //又会看到三条数据。
我们来分析下第四步,注意这句:
select * from t_viradsl2 as of timestamp to_Date('2011-01-19 15:28:00', 'yyyy-mm-dd hh24:mi:ss'),什么意思呢, 找到t_viradsl2在2011-01-19 15:28:00这个时间点的所有数据,既然找到了,你想怎么操作都可以了。
在此分享给大家