Oracle 11g 資料庫恢復:場景12續:將資料檔案恢復回原來正確的位置

LuiseDalian發表於2014-05-04

-- 部分二,做反向操作,將資料檔案還原到/oradata/TestDB11

sys@TESTDB11>shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

sys@TESTDB11>!cp /backup/inconsistent_backup/*.dbf /oradata/TestDB11

 

--確定在控制檔案中重名稱檔案需要執行的命令

sys@TESTDB11>select substr(name, length('/backup/inconsistent_backup/') + 1) from v$datafile;

 

SUBSTR(NAME,LENGTH('/BACKUP/INCONSISTENT_BACKUP/')+1)

----------------------------------------------------------------------------------------------------------------------------------------------------------------

system01.dbf

sysaux01.dbf

undotbs01.dbf

users01.dbf

example01.dbf

newundotbs01.dbf

 

6 rows selected.

 

-- 修改控制檔案中記錄的資料檔案的資訊

sys@TESTDB11>select 'alter database rename file ''' || name || ''' to ''/oradata/TestDB11/' ||

  2  substr(name, length('/backup/inconsistent_backup/') + 1) || ''';' from v$datafile;

 

'ALTERDATABASERENAMEFILE'''||NAME||'''TO''/ORADATA/TESTDB11/'||SUBSTR(NAME,LENGTH('/BACKUP/INCONSISTENT_BACKUP/')+1)||''';'

----------------------------------------------------------------------------------------------------------------------------------------------------------------

alter database rename file '/backup/inconsistent_backup/system01.dbf' to '/oradata/TestDB11/system01.dbf';

alter database rename file '/backup/inconsistent_backup/sysaux01.dbf' to '/oradata/TestDB11/sysaux01.dbf';

alter database rename file '/backup/inconsistent_backup/undotbs01.dbf' to '/oradata/TestDB11/undotbs01.dbf';

alter database rename file '/backup/inconsistent_backup/users01.dbf' to '/oradata/TestDB11/users01.dbf';

alter database rename file '/backup/inconsistent_backup/example01.dbf' to '/oradata/TestDB11/example01.dbf';

alter database rename file '/backup/inconsistent_backup/newundotbs01.dbf' to '/oradata/TestDB11/newundotbs01.dbf';

 

6 rows selected.

 

--確定控制檔案修改成功

sys@TESTDB11>select name from v$datafile;

 

NAME

--------------------------------------------------

/oradata/TestDB11/system01.dbf

/oradata/TestDB11/sysaux01.dbf

/oradata/TestDB11/undotbs01.dbf

/oradata/TestDB11/users01.dbf

/oradata/TestDB11/example01.dbf

/oradata/TestDB11/newundotbs01.dbf

 

6 rows selected.

 

--確定沒有需要恢復的檔案

sys@TESTDB11>select * from v$recover_file;

 

no rows selected

 

--啟庫

sys@TESTDB11>alter database open;

 

Database altered.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/17013648/viewspace-1153195/,如需轉載,請註明出處,否則將追究法律責任。

相關文章