一、實驗,如下: --Control fil e三個地方為: 1.1 System checkpoint SCN ===========> (SYSTEM CHECKPOINT SCN in control file) SQL> select checkpoint_change# from v$database;
CHECKPOINT_CHANGE# ------------------ 3779864
1.2 Datafile checkpoint SCN ===============> (DATAFILE CHECKPOINT SCN in control file) SQL> set lines 200 SQL> col name for a60 SQL> select name,checkpoint_change# from v$datafile;
restore datafile后,可以mount database然后去檢查controlfile and datafile header的SCN
select 'controlfile' "SCN location",name,checkpoint_change# from v$datafile where name like '%users01%' union select 'file header',name,checkpoint_change# from v$datafile_header where name like '%users01%';
3.2 RECOVER DATABASE UNTIL CANCEL USING BACKUP CONTROLFILE; ===> OPEN DATABASE RESETLOG
如果只是某TABLE被DROP掉,沒有破壞數據庫整體數據結構,還可以用NCOMPLETE RECOVERY解決 如果是某個TABLESPACE OR DATAFILE被DROP掉,因為檔案結構已經破壞,目前的CONTROL FILE內已經沒有 該DATAFILE的信息,就算你只RESTORE DATAFILE然后進行INCOMPLETE RECOVERY也無法救回被DROP的DATA FILE。
只好RESOTRE 之前備份的CONTROL FILE(里頭被DROP DATAFILE Metadata此時還存在),不過RESTOREC CONTROL FILE后 此時Oracle會發現CONTROL FILE內的SYSTEM SCN會小于目前的DATAFILE HEADER SCN,也不等于目前儲存于LOG FILE內的SCN, 此時就必須使用RECOVER DATABASE UNTIL CANCEL USING BACKUP CONTROLFILE到DROP DATAFILE OR DROP TABLESPACE之前的SCN。