oracle 闪回技术(行级)

环境:oracle10g

--创建表

create table test(
tid int primary key ,
tname varchar2(20)
);

--插入数据

insert into test values(1,'a');
insert into test values(2,'b');
insert into test values(3,'c');
insert into test values(4,'d');

--为了便于测试,等一分钟后执行下面操作

delete from test where tid = 1;

---------------------------------------------------------------------------------------------

--下面这个查询可以查看1分钟前的表数据状态(1440是系统默认值,可更改)

select * from test as of timestamp sysdate - 1/1440;

----------------------------------------------------------------------------------------------

--下面语句即用来恢复数据(当前时间的前1分钟的数据),where条件是指更新特定数据.
insert into test select * from test as of timestamp sysdate - 1/1440 where tid = 1;

-----------------------------------------------------------------------------------------------

--查看当前scn

select current_scn from v$database;

-----------------------------------------------------------------------------------------------

--查看scn数据

select * from test as of scn 1163174;

猜你喜欢

转载自koreyoshi.iteye.com/blog/1563303