天天看點

[20151028]了解資料檔案offline+drop.txt

[20151028]了解資料檔案offline+drop.txt

--前幾天做删除資料檔案的恢複測試,自己在了解offline drop的方式存在錯誤,做一個記錄:

The ALTER DATABASE DATAFILE <datafile name> OFFLINE DROP command, is not meant to allow you to remove a datafile. What

the command really means is that you are offlining the datafile with the intention of dropping the tablespace.

If you are running in archivelog mode, you can also use:

ALTER DATABASE DATAFILE <datafile name> OFFLINE;

instead of OFFLINE DROP.  Once the datafile is offline, Oracle no longer attempts to access it, but it is still

considered part of that tablespace. This datafile is marked only as offline in the controlfile and there is no SCN

comparison done between the controlfile and the datafile during startup (This also allows you to startup a database with

a non-critical datafile missing).  The entry for that datafile is not deleted from the controlfile to give us the

opportunity to recover that datafile.

alter database datafile '...' offline drop;  --非歸檔模式使用

alter database datafile '...' offline;       --歸檔模式使用

--換一句話講在歸檔模式下使用offline 或者 offline drop是一樣的,不存在差別,而在非歸檔模式僅僅使用offline drop。

--而是實際上即使加入drop也不會移除資料檔案,并且也不會從控制檔案中剔除(注:這個是最迷惑人的地方)。

--可以了解為oracle這樣設定,提示你在非歸檔下OFFLINE 一個DATAFILE 需要勇氣,因為如果需要的REDO被覆寫,你将面臨無法RECOVER

--的狀況,也就沒法ONLINE了.

--實際上在歸檔模式沒有什麼差別,在非歸檔模式必須加入drop,也許oracle想辨別要恢複有點困難,必須要有一系列日志。

--了解這些對于恢複很重要!而且drop确實有點不好了解。