flashback query 是基于 undo 表空间的,对于10g,11g的数据库是不需要额外设置的。


对于 undo_retention设置比较大,同时又设置了 retention guarantee 的数据库是大大的有用。



下面做一些简单操作演示下。


--创建临时表
create table tmp_pyb_20160418
as
select *
from dba_objects do
where 1=1
and rownum < 1000
;


--查看临时表的记录
select *
from tmp_pyb_20160418
where 1=1
;


--查看临时表的记录
select distinct owner
from tmp_pyb_20160418
where 1=1
;

OWNER
PUBLIC
OUTLN
SYS


--获取删除前的SCN
select dbms_flashback.get_system_change_number
from dual;

10806245540173


--删除临时表的一些记录
delete from tmp_pyb_20160418 tp
where 1=1
and tp.owner='SYS'
;
commit;


--临时表中owner='SYS'的记录都已经被删除了
select *
from  tmp_pyb_20160418 tp
where 1=1
  and tp.owner='SYS'
;


--使用 as of timestamp 或者 as of scn 查询删除前的数据
select *
from  tmp_pyb_20160418 as of timestamp to_timestamp('2016-04-18 10:47:00','yyyy-mm-dd hh24:mi:ss') tp
where 1=1
  and tp.owner='SYS'
;


select *
from  tmp_pyb_20160418 as of scn 10806245540173 tp
where 1=1
  and tp.owner='SYS'
;






相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-11-18
  • 2021-07-08
  • 2022-12-23
猜你喜欢
  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-07
  • 2022-02-26
  • 2021-09-25
相关资源
相似解决方案