Oracle学习(九)之删除日志组和日志文件

1.删除日志组

1)查看日志组(CURRENT状态的日志组需要切换日志,其他状态的可以删除)

SQL> select GROUP#,status from v$log;

      GROUP# STATUS  
  ---------- ----------------
           1 INACTIVE
           2 INACTIVE
           3 CURRENT
           8 UNUSED

2)删除日志组

 SQL> alter database drop logfile group 8;

   Database altered.

3)查询

SQL> select GROUP#,status from v$log;

      GROUP# STATUS
  ---------- ----------------
           1 INACTIVE
           2 INACTIVE
           3 CURRENT

2.删除日志文件

1)查看日志组(CURRENT状态的日志组需要切换日志,其他状态的可以删除)

    SQL> select GROUP#,status from v$log;

          GROUP# STATUS
      ---------- ----------------
               2 INACTIVE
               3 CURRENT

2)查看日志文件

     SQL> select GROUP#,MEMBER from v$logfile order by 1,2;

          GROUP# MEMBER
      ---------- ------------------------------------
               2 /u04/ora11g/student/redo0202.rdo
               2 /u04/ora11g/student/redo0302.rdo
               2 /u04/ora11g/student/redo0402.rdo
               3 /u05/ora11g/student/redo0103.rdo
               3 /u05/ora11g/student/redo0203.rdo
               3 /u05/ora11g/student/redo0303.rdo

      6 rows selected.

3)删除日志文件

    SQL> alter database drop logfile member 
      2  '/u04/ora11g/student/redo0402.rdo';

     Database altered.

4)查询

    SQL> select GROUP#,MEMBER from v$logfile order by 1,2;

             GROUP# MEMBER
         ---------- ------------------------------------
                  2 /u04/ora11g/student/redo0202.rdo
                  2 /u04/ora11g/student/redo0302.rdo
                  3 /u05/ora11g/student/redo0103.rdo
                  3 /u05/ora11g/student/redo0203.rdo
                  3 /u05/ora11g/student/redo0303.rdo

删除成功。

注:
删除日志组(文件)时:
1)该日志文件所在的的日志组(文件)不能处于current状态,需要执行一次手动日志切换;
SQL> alter system switch logfile;
System altered.
2)该日志文件所在的日志文件组中必须包含有其他的日志成员;
3)删除日志文件组时必须有其他的日志文件组;
4)如果数据库运行在归档模式下,则应该在删除日志文件之前,确定它所在的日志文件组已经被归档,否则会导致数据丢失。

你可能感兴趣的:(Oracle数据库学习)