oracle回闪操作

查询test表中记录
select * from test;

删除test表中记录
delete from test;

获得过去的会话
exec dbms_flashback.disable;

查询出3分钟前这个test表的情况
select * from test as of timestamp(systimestamp - interval '3' minute );
最大时间值为8277,但不知道该值是根据什么来变化的?

将查出的记录插入到误删除数据的表中
insert into test select * from test as of timestamp(systimestamp - interval '30' minute );


两种方法:
1、使用dbms_flshback
闪回:DBMS_FLASHBACK.enable_at_time(to_timestamp('2006-5-24 8:26:0', 'yyyy-mm-dd hh24:mi:ss'))
_changexec dbms_flashback.enable_at_systeme_number(4143031890000);--change number
取消闪回:exec dbms_flashback.disable

2、语句级
select * from dept as of scn 4143031890000);--change number
select * from dept as of timestamp(to_timestamp('2006-5-24 8:26:0', 'yyyy-mm-dd hh24:mi:ss'));



在10G上执行的操作
例:执行将test表闪回到2005年5月7日下午3点。
SQL>flashback table test to timestamp to_timestamp('2005-05-07 15:00:00','yyyy-mm-dd hh24:mi:ss');


修改数据库中某些字段存在的空格
update laagent set name=replace(name,' ','') where agentcode='116000001'

猜你喜欢

转载自lihua2008love.iteye.com/blog/2238330