在操作Oracle的过程中,有的时候会误操作表数据,例如更新或者删除,如何找到误操作前的数据呢?Oracle提供了闪回技术,可以访问过去某一时间的数据(如果时间太长或者操作过于频繁有可能找不到),
?
举例,创建表test_sj_salary,初始化脚本
?
create table test_sj_salary ( id integer primary key, name varchar2(100), salary integer ); insert into test_sj_salary (ID, NAME, SALARY) values (1, ‘张三‘, 5000); insert into test_sj_salary (ID, NAME, SALARY) values (2, ‘李四‘, 4000); insert into test_sj_salary (ID, NAME, SALARY) values (3, ‘王五‘, 6000); insert into test_sj_salary (ID, NAME, SALARY) values (4, ‘李六‘, 3500); commit;
?
?
插入了4条数据,如图
?
?
?
操作,例如删除张三的数据
?
delete test_sj_salary where name=‘张三‘; commit;
?
?
如何找回删除张三前的数据呢?使用这种方法找回
?
select * from test_sj_salary as of timestamp(systimestamp - interval ‘1‘ minute); 其中minute前面的数字根据需要可以修改
?
执行后能够查询到原来的数据
?
?
?
?
?
?
?
?
原文:http://wodeguozili.iteye.com/blog/2302132