zoukankan      html  css  js  c++  java
  • Oracle闪回恢复

    Oracle的闪回功能包括

    1.闪回数据库(前提 归档模式下 启用闪回数据库) mount 下 alter database archivelog; alter database flashback on ;
    2.闪回回收站
    3.闪回表
    4.闪回查询
      4.1 闪回查询表 SCN 时间 timestamp
      4.2 闪回版本查询 versions_xid
      4.3 闪回事物查询 flashback_transaction_query

    (一)闪回表 

    flashback table
    启动行移动 功能,如果不启动
    SQL> flashback table scott.emp to scn 1101462;
    flashback table scott.emp to scn 1101462
    *
    第 1 行出现错误:
    ORA-08189: 因为未启用行移动功能, 不能闪回表

    alter table emp enable row movement;

    flashback table hz_test_recycle to timestamp to_date('20110111123000','yyyymmddhh24miss')

    存在限制:

    不可以跨越ddl 操作
    不可以闪回system表

    (二)闪回回收站

    启用 回收站 recyclebin
    SQL> show parameter recyclebin

    NAME TYPE
    ------------------------------------ --------------------------------
    VALUE
    ------------------------------
    recyclebin string
    on

    测试

    grant dba to scott;
    create table wj(id number(5) primary key,name varchar2(20));
    insert into wj (1,'dwj');
    create materialized view log on wj with primary key; -
    create materialized view mv_wj refresh fast on commit ;--创建物化视图
    as
    select * from wj;

    insert into wj values(2,'yj');

    show recyclebin
    drop table wj
    flashback table wj to before drop;
    insert into wj(3,'nr1');
    select * from mv_wj;
    commit; 报错 --无法闪回视图日志 需要重建

    (三)闪回查询

    delete from emp where deptn=30;

    select * from emp as of timestamp to_timestamp('2010-01-09 10:00:45','YYYY-MM-DD HH24:MI:SS')
    where deptno=30 --利用回滚段里东西

    (四)闪回版本查询

    select versions_xid,salary from employees versions between timestamp t1 and t2 where emplyee_id =200;
      -- versions_xid 是伪列

    update emp
    set sal=2800
    where ename='SMITH'

    select sal from emp versions between scn minvalue and maxvalue where ename='SMITH'

    哪些情况下不可以做:

    --外部表
    --临时表
    --FIXED表
    --视图
    --不能跨越DDL

    (五)闪回事务查询

    flashback_transaction_query --视图
    查询语句在哪个事物当中 取得事物号

    select empno,ename,sal,versions_operation,versions_xid,versions_starttime,versions_endtime,versions_operation from emp versions between timestamp minvalue and maxvalue;

    select logon_user,table_name,table_owner,undo_sql from flashback_transaction_query where table_owner='SCOTT' and xid
    ='';

  • 相关阅读:
    封装cookie
    敏感词过滤
    面向对象改成选项卡
    正则表达式
    cookie
    DOM
    系统对象
    cookie记录用户名
    6个原则
    23中设计模式
  • 原文地址:https://www.cnblogs.com/staryea/p/8523482.html
Copyright © 2011-2022 走看看