alter system switch logfile與alter system archive log current 區別

alter system switch logfile 是強制日誌切換,不一定就歸檔當前的重做日誌文件(若自動歸檔打開,就歸檔前的重做日誌,若自動歸檔沒有打開,就不歸檔當前重做日誌。)
alter system archive log current 是歸檔當前的重做日誌文件,不管自動歸檔有沒有打都歸檔。
主要的區別在於:
ALTER SYSTEM SWITCH LOGFILE對單實例數據庫或RAC中的當前實例執行日誌切換;
而ALTER SYSTEM ARCHIVE LOG CURRENT會對數據庫中的所有實例執行日誌切換。
爲什麼執行熱備後要執行alter system archive log current 這個語句,看到很多腳本都是這樣寫的。
是不是必須的?

一般的RMAN腳本都是這樣寫的,因爲RMAN是可以備份歸檔日誌的。alter system archive log current 這樣後就可以將所有的歸檔都備份出來了。這樣做是爲了保證數據的完整和一致。

ALTER SYSTEM SWITCH LOGFILE ;
SWITCH LOGFILE Clause
The SWITCH LOGFILE clause lets you explicitly force Oracle to begin writing to a new redo log file group, regardless of whether the files in the current redo log file group are full. When you force a log switch, Oracle begins to perform. a checkpoint but returns control to you immediately rather than when the checkpoint is complete. To use this clause, your instance must have the database open.

ALTER SYSTEM ARCHIVE LOG CURRENT ;
CURRENT Clause
Specify CURRENT to manually archive the current redo log file group of the specified thread(instance), forcing a log switch. If you omit the THREAD parameter, then Oracle archives all redo log file groups from all enabled threads(instances), including logs previous to current logs. You can specify CURRENT only when the database is open.

ALTER SYSTEM ARCHIVE LOG CURRENT NOSWITCH;
NOSWITCH
Specify NOSWITCH if you want to manually archive the current redo log file group without forcing a log switch. This setting is used primarily with standby databases to prevent data divergence when the primary database shuts down. Divergence implies the possibility of data loss in case of primary database failure.

You can use the NOSWITCH clause only when your instance has the database mounted but not open. If the database is open, then this operation closes the database automatically. You must then manually shut down the database before you can reopen it.

發佈了19 篇原創文章 · 獲贊 3 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章