Oracle手動切換記錄檔和清空記錄檔

來源:互聯網
上載者:User

Oracle手動切換記錄檔和清空記錄檔

Oracle切換記錄檔組
記錄檔組是迴圈使用的,當一組記錄檔被寫滿時,Oracle系統自動的切換到下一組記錄檔。在需要的時候,資料庫管理員也可以手動的切換到其他的記錄檔組。切換記錄檔組需要使用如下的語句:
alter system switch logfile;

清空記錄檔組
如果記錄檔組中的記錄檔受損,將導致資料庫無法將受損的記錄檔進行歸檔,這會最終導致資料庫停止運行。此時,在不關閉資料庫的情況下,可以選擇清空記錄檔組中的內容。
清空記錄檔組的文法如下:
alter database clear logfile group group_number;
注意:
被清空的記錄檔組不能處於current狀態,也就是說不能清空資料庫當前正在使用的記錄檔組。
當資料庫中只有兩個記錄檔組時,不能清空記錄檔組。
具體的操作如下:
SQL> select group#,status from v$log;    //查看記錄檔住的狀態
    GROUP# STATUS
---------- ----------------
        1 ACTIVE                  --活動窗檯
        2 INACTIVE                --非使用中
        3 INACTIVE
        4 CURRENT                --當前資料庫正在使用的記錄檔組
SQL> alter system switch logfile;
系統已更改。
由以下可以看出此時的資料庫檔案組的已經被更改。
SQL> select group#,status from v$log;
    GROUP# STATUS
---------- ----------------
        1 INACTIVE
        2 CURRENT
        3 INACTIVE
        4 ACTIVE
清空記錄檔組,對檔案進行初始化操作,檔案並沒被刪除,知識內容被清空
Alter database clear logfile group 4;

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.