Oracle FlashBack ---- 2016-05-04

Application of Oracle FlashBack function

In our daily work, we sometimes accidentally delete some data that we do not want to delete. At this time, you can restore the data through flashback. The landlord does not understand its principle, and here only contains some simple applications.

1. Directly restore a table to a certain point in time.

delete from Table ~~;

select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

alter table Table~~ enable row movement;

flashback table Table~~ to timestamp to_timestamp('2016-02-20 14:31:43','yyyy-mm-dd hh24:mi:ss');

 2. If some new records are inserted into the table after the data is deleted, then the direct recovery will delete the following data. It can be recovered in the following way.

insert into Table ~~
select * from Table ~~
as of timestamp to_timestamp('2016-02-20 11:45:13','YYYY-MM-DD HH24:MI:SS');

In the above sql, you can also compare the difference between the data in the table now and a certain point in the past to exclude duplicate data.

insert into Table~~(select * from  Table~~as of timestamp to_timestamp('2016-05-03 14:24:29','yyyy-mm-dd hh24:mi:ss')
where some_Column not in (select some_Column  from Table~~ ));

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326933625&siteId=291194637