Oracle Flashback Database

  1. Ensure that the prerequisites described in Prerequisites of Flashback Database are met.

    To use the FLASHBACK DATABASE command to return your database contents to points in time within the flashback window, your database must have been previously configured for flashback logging as described in "Overview of Flashback Database_ Restore Points and Guaranteed Restore Points". To return the database to a guaranteed restore point, you must have previously defined a guaranteed restore point as described in "Using Normal and Guaranteed Restore Points".
    
    Flashback Database works by undoing changes to the data files that exist at the moment that you run the command. Note the following important prerequisites:
    
    No current data files are lost or damaged. You can only use FLASHBACK DATABASE to rewind changes to a data file made by an Oracle database, not to repair media failures.
    
    You are not trying to recover from accidental deletion of data files, undo a shrink data file operation, or undo a change to the database name.
    
    You are not trying to use FLASHBACK DATABASE to return to a point in time before the restore or re-creation of a control file. If the database control file is restored from backup or re-created, then all accumulated flashback log information is discarded.
    
    You are not trying to use FLASHBACK DATABASE to undo a compatibility change.

    Prerequisites

  2. Connect SQL*Plus to the target database and determine the desired SCN, restore point, or point in time for the FLASHBACK DATABASE command.

    Obtain the earliest SCN in the flashback database window as follows:

    SELECT OLDEST_FLASHBACK_SCN, OLDEST_FLASHBACK_TIME
    FROM V$FLASHBACK_DATABASE_LOG;

    The most recent SCN that can be reached with Flashback Database is the current SCN of the database. The following query returns the current SCN:

    SELECT CURRENT_SCN
    FROM V$DATABASE;

    You can query available guaranteed restore points as follows (sample output included):

    SELECT NAME, SCN, TIME, DATABASE_INCARNATION#,
    GUARANTEE_FLASHBACK_DATABASE
    FROM V$RESTORE_POINT
    WHERE GUARANTEE_FLASHBACK_DATABASE='YES'; NAME SCN TIME DATABASE_INCARNATION# GUA
    --------------- ---------- --------------------- --------------------- ---
    BEFORE_CHANGES 5753126 04-MAR-12 12.39.45 AM 2 YES
  3. Shut down the database consistently, ensure that it is not opened by any instance, and then mount it:
    SHUTDOWN IMMEDIATE;
    STARTUP MOUNT;
  4. Repeat the query in Step 2 of this procedure.

    Some flashback logging data is generated when the database is shut down. If flashback logs were deleted due to space pressure in the fast recovery area, then your target SCN may not be reachable.

  5. Start RMAN and connect to the target database.
  6. Run the SHOW command to see which channels are preconfigured.

    During the flashback operation, RMAN may need to restore archived redo logs from backup. Enter the following command to see whether channels are configured (sample output is included):

    SHOW ALL;
    
    RMAN configuration parameters for database with db_unique_name PROD1 are:
    .
    .
    .
    CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
    CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
    CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
    CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/usr/local/oracle/backup/lib/libobk.so";

    If the necessary devices and channels are configured, then no action is necessary. Otherwise, use the CONFIGURE command to configure automatic channels, or include ALLOCATE CHANNELcommands within a RUN block.

  7. Run the RMAN FLASHBACK DATABASE command.

    You can specify the target time by using a form of the command shown in the following examples:

    FLASHBACK DATABASE TO SCN 46963;
    
    FLASHBACK DATABASE
    TO RESTORE POINT BEFORE_CHANGES; FLASHBACK DATABASE TO TIME
    "TO_DATE('09/20/12','MM/DD/YY')";

    When the FLASHBACK DATABASE command completes, the database is left mounted and recovered to the specified target time.

  8. Open the database read-only in SQL*Plus and run some queries to verify the database contents.

    Open the database read-only as follows:

    ALTER DATABASE OPEN READ ONLY;
    

    If you are satisfied with the state of the database, then end the procedure with Step 9. If you are not satisfied with the state of the database, skip to Step 10.

  9. If you are satisfied with the results, then perform either of the following mutually exclusive actions:
    • Make the database available for updates by opening the database with the RESETLOGS option. If the database is currently open read-only, then execute the following commands in SQL*Plus:

      SHUTDOWN IMMEDIATE
      STARTUP MOUNT
      ALTER DATABASE OPEN RESETLOGS;
    • Use Oracle Data Pump Export to make a logical backup of the objects whose state was corrupted. Afterward, use RMAN to recover the database to the present time:

      RECOVER DATABASE;
      

      This step undoes the effect of the Flashback Database by reapplying all changes in the redo logs to the database, returning it to the most recent SCN.

      After reopening the database read/write, you can import the exported objects with the Data Pump Import utility. See Oracle Database Utilities to learn how to use Data Pump.

  10. If you find that you used the wrong restore point, time, or SCN for the flashback, then mount the database and perform one of the following mutually exclusive options:
    • If your chosen target time was not far enough in the past, then use another FLASHBACK DATABASE command to rewind the database further back in time:

      FLASHBACK DATABASE TO SCN 42963;  #earlier than current SCN
      
    • If you chose a target SCN that is too far in the past, then use RECOVER DATABASE UNTIL to wind the database forward in time to the desired SCN:

      RECOVER DATABASE UNTIL SCN 56963; #later than current SCN
      
    • If you want to completely undo the effect of the FLASHBACK DATABASE command, then you can perform complete recovery of the database by using the RECOVER DATABASE command without an UNTIL clause or SET UNTIL command:

      RECOVER DATABASE;
      

      The RECOVER DATABASE command reapplies all changes to the database, returning it to the most recent SCN.

最新文章

  1. VB程序架构分析
  2. C程序中常见的内存操作错误
  3. C++ 之引用
  4. java 枚举类型分析
  5. BZOJ3613 南园满地堆轻絮-二分法
  6. sqlserver查询某一字段重复超5次的所有记录
  7. [置顶] android开发之来电自动拒接并自动回复短信_上课模式app
  8. ABP 学习汇总
  9. File重要获取功能
  10. 配置linux-Fedora系统下iptables防火墙
  11. 修改Ubuntu的aptget源为阿里源的方法
  12. openfiler简介
  13. 网站钓鱼的方法 和 xss
  14. Solr使用in语法查询
  15. [转]order by 与索引
  16. 从零开始学Kotlin-扩展函数(10)
  17. Intel 设计缺陷背后的原因是什么? | Linux 中国
  18. ztree参考
  19. 企业大数据之Elasticsearch的搜索类型
  20. 转载----C/C++ 中 const 修饰符用法总结

热门文章

  1. numpy库中数组的数据类型
  2. Django使用Celery进行异步任务
  3. 安装Pycharm(方便编辑代码的IDE(编辑器))以及 使用Pycharm新建项目
  4. 数学: HDU Co-prime
  5. Ubantu创建热点并共享——2019年5月10日更新
  6. HDU 1594 find the max
  7. 检验Excel中数据是否与数据库中数据重复
  8. react找到对象数组中指定的值
  9. editplus的使用技巧
  10. hdu4731 Minimum palindrome (找规律)