RMAN> recover database until scn 566592;until scn只能在RMAN下进行
sql>recover database until time '2008-07-29 09:43:35';
sql>recover database using backup controlfile until cancel;
STEP1:RMAN>backup database;
STEP2:SQL> update linren set empno=1000 where ename='SMITH';
1 row updated.
SQL> commit; #log seq=1
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> update linren set empno=1000 where ename='ALLEN';
1 row updated.
SQL> commit;
SQL> alter system switch logfile;
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
STEP3:删除控制文件
STEP4:从备份中恢复控制文件SQL> startup nomount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 71305460 bytes
Database Buffers 92274688 bytes
Redo Buffers 2973696 bytes
RMAN> restore controlfile from '/home/oracle/oracle/product/10.2.0/db_1/flash_recovery_area/ORCL/backupset/2008_07_28/o1_mf_ncsnf_TAG20080728T160448_48tzg61l_.bkp';
SQL> startup mount
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 71305460 bytes
Database Buffers 92274688 bytes
Redo Buffers 2973696 bytes
Database mounted.
RMAN> restore database;
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 517595 generated at 07/28/2008 16:04:49 needed for thread 1
ORA-00289: suggestion : /home/oracle/archivelog/arch1_1_661277010.arc
ORA-00280: change 517595 for thread 1 is in sequence #1
Specify log: {
ORA-00279: change 517650 generated at 07/28/2008 16:06:54 needed for thread 1
ORA-00289: suggestion : /home/oracle/archivelog/arch1_2_661277010.arc
ORA-00280: change 517650 for thread 1 is in sequence #2
ORA-00278: log file '/home/oracle/archivelog/arch1_1_661277010.arc' no longer
needed for this recovery
Specify log: {
CANCEL
Media recovery cancelled.
SQL> select empno,ename from linren;
EMPNO ENAME
---------- ----------
1000 SMITH
22 ALLEN
只应用了seq 为1的archivelog。
rman>restore database;
SQL> recover database until time '2008-07-29 09:43:35';
ORA-00279: change 565731 generated at 07/29/2008 09:42:14 needed for thread 1
ORA-00289: suggestion : /home/oracle/archivelog/arch1_1_661340423.arc
ORA-00280: change 565731 for thread 1 is in sequence #1
Specify log: {
AUTO
Log applied.
Media recovery complete.
SQL> alter database open resetlogs;
until cancel;
ORA-00279: change 517595 generated at 07/28/2008 16:04:49 needed for thread 1
ORA-00289: suggestion : /home/oracle/archivelog/arch1_1_661277010.arc
arch1_1_661277010.arc就已经是最后的arch log了,不能做到不完全恢复
总结:until time,cancel等需要先restore databae.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7301064/viewspace-412018/ ,如需转载,请注明出处,否则将追究法律责任。