日期:2014-05-16  浏览次数:20378 次

Oracle闪回操作

Oracle闪回操作

1. 记录当前时间或SCN

在数据库变动前记录时间或SCN

SQL> select  to_char(sysdate,'YYYY-MM-DD HH24:mi:ss') from dual;

SQL> select  current_scn from v$database;

 

 2.开启闪回

开启闪回需要数据库在归档模型下,所以首先需要开启归档。并且在mount状态下。

首先查看是否开启闪回:

SQL> select flashback_on from V$database;

FLASHBACK_ON

------------------

NO

如果已经开启了闪回,无须执行下面的操作。

SQL> alter system set db_recovery_file_dest_size=30G scope=both;

SQL> alter system set db_recovery_file_dest='/u01/flashback'  scope=both;

SQL> shutdown immediate

SQL> startup mount

SQL> alter database archivelog;

SQL> alter database flashback on;

SQL> alter database open;

再进行确认:

SQL> select flashback_on from V$database;

FLASHBACK_ON

------------------

YES

 

3.闪回操作

3.1闪回数据库

SQL >flashback database to time to_date(xxx);
SQL >flashback database to time TO_TIMESTAMP (xxx);
SQL >flashback database to scn xxx
SQL >flashback database to sequence xxx thread 1
SQL>flashback database to timestamp(sysdate-1/24)

3.2闪回表