操作系统版本:Solaris 5.8 Sparc 64bit
数据库版本:Oracle 9.2.0.1
一直以为”alter database recover”和”recover database”这两个命令除了前者是SQL命令后者是SQL*PLUS命令之外,其它都是相同的,实际上却有所出入。
在所有需要的归档日志都存在的相同前提下。alter database recover命令无法继续。
SQL> alter database recover using backup controlfile until cancel;
alter database recover using backup controlfile until cancel
*
ERROR at line 1:
ORA-00279: change 10402260063 generated at 10/31/2009 01:30:52 needed for
thread 1
ORA-00289: suggestion : /xf_arch1/log9565_1.arc
ORA-00280: change 10402260063 for thread 1 is in sequence #9565
但是recover database命令却可以让DBA继续输入log file的名称。
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 10402260063 generated at 10/31/2009 01:30:52 needed for
thread 1
ORA-00289: suggestion : /xf_arch1/log9565_1.arc
ORA-00280: change 10402260063 for thread 1 is in sequence #9565
Specify log: {=suggested | filename | AUTO | CANCEL}
/xf_arch1/log9565_1.arc
ORA-00279: change 10402260063 generated at 10/30/2009 23:24:14 needed for
thread 2
ORA-00289: suggestion : /xf_arch1/log10763_2.arc
ORA-00280: change 10402260063 for thread 2 is in sequence #10763
Specify log: {=suggested | filename | AUTO | CANCEL}
/xf_arch1/log10763_2.arc
ORA-00279: change 10402782605 generated at 10/31/2009 06:21:30 needed for
thread 1
ORA-00289: suggestion : /xf_arch1/log9566_1.arc
ORA-00280: change 10402782605 for thread 1 is in sequence #9566
ORA-00278: log file '/xf_arch1/log9565_1.arc' no longer needed for this
recovery
Specify log: {=suggested | filename | AUTO | CANCEL}
CANCEL
Media recovery cancelled.
SQL>
SQL> alter database open resetlogs;
Database altered.
在上例中如果要想alter database recover成功,需要如下的语法:
ALTER DATABASE RECOVER automatic database
until change 10404040058 using backup controlfile;
或者:
alter database recover logfile '/xf_arch1/log9565_1.arc' using backup controlfile;
a) use ALTER DATABASE if you want to do the recoverying step by step, manually — issueing each and every single solitary command to recover the database (apply logfiles).
b) use the SQLPLUS ‘recover’ command to have sqlplus automate the steps in a) for you.
更加详细的描述可以参看AskTOM的解释。