摘要:《沒有catalog及controlfile restore datafile》
2009/6/19
心血來潮將redo log全部刪除後,想藉由不完全恢復重建資料庫,
一直遇到redo logfile group 3 是active的log,無法刪除也無法switch logfile,
打算放棄,從rman備份資料中復原,結果control file 找不到備份的資訊,也就restore不回去;
就找到了不用control file而用oracle提供的dbms_backup_restore.restoreDatafileTo,
沒想到有這玩意,雖然restore後,還是因為system01.dbf需要recover的錯誤,至今還不知道怎麼將資料庫打開,
不過倒是找到個好玩意,在這跟大家分享。
DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'I1');
sys.dbms_backup_restore.restoreSetDatafile;
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>1,toname=> 'C:\ORACLE\ORADATA\ORACLEA\SYSTEM01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>2,toname=> 'C:\ORACLE\ORADATA\ORACLEA\UNDOTBS01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>3,toname=> 'C:\ORACLE\ORADATA\ORACLEA\CWMLITE01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>4,toname=> 'C:\ORACLE\ORADATA\ORACLEA\DRSYS01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>5,toname=> 'C:\ORACLE\ORADATA\ORACLEA\EXAMPLE01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>6,toname=> 'C:\ORACLE\ORADATA\ORACLEA\INDX01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>7,toname=> 'C:\ORACLE\ORADATA\ORACLEA\ODM01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>8,toname=> 'C:\ORACLE\ORADATA\ORACLEA\TOOLS01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>9,toname=> 'C:\ORACLE\ORADATA\ORACLEA\USERS01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>10,toname=> 'C:\ORACLE\ORADATA\ORACLEA\XDB01.DBF');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>11,toname=> 'C:\ORACLE\ORADATA\ORACLEA\ORATEXT01.DBF');
sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'C:\BackupDB\FULLDBBACKUP_0CKI0LV1_1_1', params=>null);
sys.dbms_backup_restore.deviceDeallocate;
END;
---------------------------------------------------------------------------------------------------------------
後記:
往前翻筆記,找到之前寫的一篇,[ORA-01152: 檔案 1 不是自一個夠早的備份中復原回來的],
按表操課果然是有用的,重建control file再open resetlogs,終於將資料庫救了回來。