Using Oracle Flashback Technology to Recover Misoperation Data

In the process of operating Oracle, sometimes table data is mis-manipulated, such as updating or deleting. How to find the data before mis-operation? Oracle provides flashback technology, which can access data at a certain time in the past (if the time is too long or the operation is too frequent, it may not be found),

 

For example, create table test_sj_salary, initialize script

 

create table test_sj_salary
(
   id integer primary key,
   name varchar2(100),
   salary integer
);

insert into test_sj_salary (ID, NAME, SALARY)
values ​​(1, 'Zhang San', 5000);

insert into test_sj_salary (ID, NAME, SALARY)
values ​​(2, 'Li Si', 4000);

insert into test_sj_salary (ID, NAME, SALARY)
values ​​(3, 'Wang Wu', 6000);

insert into test_sj_salary (ID, NAME, SALARY)
values ​​(4, 'Li Liu', 3500);

commit;

 

 

4 pieces of data are inserted, as shown in the figure

 

 

 

operations, such as deleting Zhang San's data

 

delete test_sj_salary where name='张三';
commit;

 

 

How to retrieve the data before deleting Zhang San? use this method to retrieve

 

select *
from test_sj_salary
as of timestamp (systimestamp - interval '1' minute);

The number in front of minute can be modified as needed

 

After execution, the original data can be queried

 

 

 

 

 

 

 

 

Guess you like

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