--kf是误删除的表
SQL> select count(*) from kf;
COUNT(*)
----------
3
SQL> delete from kf;
3 rows deleted
SQL> select count(*) from kg;
COUNT(*)
----------
0
--查询此时数据库的SCN
SQL>select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
614215
SQL> select count(*) from kf as of scn 614215;
COUNT(*)
----------
0
--创建临时表test存放数据库的SCN
SQL> create table test(count int,scn int);
Table created
SQL> DECLARE
i INT:=614200;
BEGIN
FOR i IN 614200..614217 LOOP
INSERT INTO howard( SCN) VALUES (i );
UPDATE howard SET COUNT =(SELECT COUNT(*) FROM kg AS OF SCN i) WHERE SCN= i;
END LOOP ;
END ;
/
SQL> SELECT * FROM test
SQL> /
COUNT SCN
--------------------------------------- ---------------------------------------
3 614202
3 614203
3 614204
0 614205
0 614206
--得到删除前数据库的SCN,恢复表数据
SQL> select count(*) from kf as of scn 614204;
COUNT(*)
----------
3
SQL> select count(*) from kg as of scn 614205;
COUNT(*)
----------
0
SQL>insert into kf select * from kf as of scn 614204;
3 rows inserted