加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle闪回技术

发布时间:2020-12-12 13:36:41 所属栏目:百科 来源:网络整理
导读:undo数据保留7天 orcl show parameter undo NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ _optimizer_undo_cost_change string 12.1.0.2 temp_undo_enabled boolean FALSE undo_management string AUT

undo数据保留7天
orcl> show parameter undo

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
_optimizer_undo_cost_change string 12.1.0.2
temp_undo_enabled boolean FALSE
undo_management string AUTO
undo_retention integer 604800
undo_tablespace string UNDOTBS1
orcl> select 604800/60/60/24 from dual;

604800/60/60/24
---------------
7

1:闪回查询,利用undo

查询指定时间点的表数据

select * from scott.acct as of timestamp TO_TIMESTAMP(‘2018-05-20 15:30:00‘,‘ yyyy-mm-dd hh24:mi:ss‘)? WHERE user_id = 1;

2:闪回表

闪回表(Flashback table)是利用undo信息来恢复表对象到以前的某一个时间点(一个快照)

SQL>flashback table test to timestamp to_timestamp(‘2018-05-20 15:30:00‘,‘ yyyy-mm-dd hh24:mi:ss‘) ;

SQL>flashback table test to timestamp scn 115544;

SQL>flashback table test to timestamp to_timestamp(‘2018-05-20 15:30:00‘,‘ yyyy-mm-dd hh24:mi:ss‘) enable triggers;

运用闪回表前提?

1)普通用户中需要有Flashback any table的系统权限。命令如:?

  SQL>grant flashback any table?to?scott;?

2)有该表的select、insert、delete、alter权限。?

3)必须保证该表有row movement(行移动)。

恢复表到过去的某个时间点,恢复test表到刚记录的时间点(或scn),由于表中存在触发器,因此使用了关键字enable triggers;

flashback table test to timestamp to_timestamp(‘2018-05-20 15:30:00‘,‘ yyyy-mm-dd hh24:mi:ss‘) enable triggers;

?

3:闪回数据归档

查询过去一段时间的状态

select versions_startscn,versions_endscn,versions_starttime,versions_endtime,versions_xid,versions_operation,ORDER_ID from scott.emp WHERE ORDER_ID in (100827979,100827973,100785947);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读