1、 环境:操作系统aix5.2,数据库Oracle9.2
2、 模拟环境:
1)首先使用rman作整个数据库备份
2)时间:
# date
Tue Aug 23 17:35:19 BEIDT 2005
3)操作:
sql>truncate table scott.emp
3、 恢复数据库到2005年8月23日17点35分19秒
4、 数据库到mount状态
5、 设置变量
$set nls_date_format=yyyy-mm-dd:hh24:mi:ss
6、 连接到rman
$rman target / catalog rman/rman@omsora9
RMAN> run {
2> set until time="to_date('2005-08-23:17:35:19','yyyy-mm-dd:hh24:mi:ss')";
3> restore database;
4> recover database;
5> }
executing command: SET until clause
Starting restore at 23-AUG-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=14 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=15 devtype=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: sid=16 devtype=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: sid=17 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /oradata/hb130000/cwmlite01.dbf
restoring datafile 00010 to /oradata/hb130000/xdb01.dbf
restoring datafile 00012 to /oradata/hb130000/GFB.DBF
restoring datafile 00013 to /oradata/hb130000/CA.dbf
restoring datafile 00017 to /oradata/hb130000/GDSS.dbf
channel ORA_DISK_2: starting datafile backupset restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /oradata/hb130000/drsys01.dbf
restoring datafile 00005 to /oradata/hb130000/example01.dbf
restoring datafile 00006 to /oradata/hb130000/indx01.dbf
restoring datafile 00014 to /oradata/hb130000/QUEST.dbf
restoring datafile 00018 to /oradata/hb130000/FPJKDB.dbf
channel ORA_DISK_3: starting datafile backupset restore
channel ORA_DISK_3: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /oradata/hb130000/undotbs01.dbf
restoring datafile 00007 to /oradata/hb130000/odm01.dbf
restoring datafile 00009 to /oradata/hb130000/users01.dbf
restoring datafile 00011 to /oradata/hb130000/YSZX130000002005.DBF
restoring datafile 00015 to /oradata/hb130000/FOGLIGHT.dbf
channel ORA_DISK_4: starting datafile backupset restore
channel ORA_DISK_4: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oradata/hb130000/system01.dbf
restoring datafile 00008 to /oradata/hb130000/tools01.dbf
restoring datafile 00016 to /oradata/hb130000/gwd.dbf
restoring datafile 00019 to /oradata/hb130000/tgggg.dbf
channel ORA_DISK_2: restored backup piece 1
piece handle=/oradata/rmanbackup/df_HB130000_567080235_66_1.bak tag=TAG20050823T
101715 params=NULL
channel ORA_DISK_2: restore complete
channel ORA_DISK_3: restored backup piece 1
piece handle=/oradata/rmanbackup/df_HB130000_567080235_67_1.bak tag=TAG20050823T
101715 params=NULL
channel ORA_DISK_3: restore complete
channel ORA_DISK_1: restored backup piece 1
piece handle=/oradata/rmanbackup/df_HB130000_567080236_68_1.bak tag=TAG20050823T
101715 params=NULL
channel ORA_DISK_1: restore complete
channel ORA_DISK_4: restored backup piece 1
piece handle=/oradata/rmanbackup/df_HB130000_567080237_69_1.bak tag=TAG20050823T
101715 params=NULL
channel ORA_DISK_4: restore complete
Finished restore at 23-AUG-05
Starting recover at 23-AUG-05
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
starting media recovery
archive log thread 1 sequence 4 is already on disk as file /oradata/rmanbackup/a
rchive/hb130000_1_4.dbf
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=3
channel ORA_DISK_1: restored backup piece 1
piece handle=/oradata/rmanbackup/df_HB130000_567080296_72_1.bak tag=TAG20050823T
101815 params=NULL
channel ORA_DISK_1: restore complete
archive log filename=/oradata/rmanbackup/archive/hb130000_1_3.dbf thread=1 seque
nce=3
media recovery complete
Finished recover at 23-AUG-05
RMAN>
7、 连接到数据库
$sqlplus nolog
sql>conn / as sysdba
connected
sql>alter database open resetlogs
database altered.
8、查询表scott.emp数据得到恢复。