Oracle Flashback Technologies - 闪回数据库

时间:2024-11-30 17:32:56

Oracle Flashback Technologies - 闪回数据库

根据指定的SCN,使用rman闪回数据库

#查看可以闪回到多久前

SQL> select * from v$flashback_database_log;

#查看当前的SCN

SQL> select current_scn from v$database;

CURRENT_SCN
----------- SQL>

#关闭数据库

$ rman target /

Recovery Manager: Release 11.2.0.4. - Production on Tue Jun  :: 

Copyright (c) , , Oracle and/or its affiliates.  All rights reserved.

connected to target database: DBTEST (DBID=)

RMAN> shutdown immediate

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

#mount数据库

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted Total System Global Area bytes Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes

根据SCN闪回数据库

RMAN> flashback database to scn ;

Starting flashback at -JUN- ::
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID= device type=DISK starting media recovery
media recovery complete, elapsed time: :: Finished flashback at -JUN- ::

#以resetlogs打开数据库。闪回数据库是基于时间点的恢复,是不完全恢复,要是resetlogs方式打开

RMAN> alter database open resetlogs;

database opened

RMAN> 

此外还可以用以下方式闪回数据库:

#根据时间闪回数据库

RMAN> flashback database to time "to_date('2015-06-23 06:25:00','yyyy-mm-dd hh24:mi:ss')";

#根据restore point闪回数据库

RMAN> flashback database to restore point rp;

#闪回到上一次resetlogs操作之前

RMAN> flashback database to before resetlogs;

以上操作命令,也可以在sql*plus下完成。