1、首先查看当前数据库是否处于归档模式
可使用如下两种方式查看
1.1
select name, log_mode from v$database;

log_mode的值为 NOARCHIVELOG 表示数据库处于非归档模式

log_mode的值为 ARCHIVELOG 表示数据库处于归档模式
1.2
archive log list; (此方法需要 as sysdba)

Database log mode 的值为 No Archive Mode
Automatic archival 的值为 Disabled
表示当前数据库处于非归档模式

Database log mode 的值为 Archive Mode
Automatic archival 的值为 Enabled
表示数据库已开启归档模式
2、非归档模式的数据库更改为归档模式
数据库从非归档模式更改为归档模式需要数据库处于mount状态下。
以下操作适用于oracle10g以上版本,对于oracle8i和9i不适用。
2.1 关闭数据库
shutdown immediate;

2.2 启动数据库到mount状态
startup mount;

2.3 修改数据库为归档模式
alter database archivelog;

2.4 打开数据库
alter database open;

2.5 查询数据库是否已处于归档模式
archive log list;

数据库已由非归档模式更改为归档模式
2.6 修改日志文件命名格式
alter system set log_archive_max_processes = 5;
alter system set log_archive_format = "archive_%t_%s_%r.log" scope=spfile;

此处修改后如果重启,则重启后归档的日志文件格式会更改为 archive_%t_%s_%r.log 格式,否则仍是默认的格式。
2.7 更改日志文件路径
alter system set log_archive_dest_1=‘location=/data/archivelog/orcl‘;

此时 Archive destination的值更改为 /data/archivelog/orcl
该语句含义是确定归档日志的路径,实际上Oracle 10g以后可以生成多份一样的日志,保存多个位置,以防不测
例如再添加一个日志位置可使用以下语句
SQL>alter system set log_archive_dest_2=‘location=/bak/orcl/archive_log‘;
2.8 归档当前重做日志
select name from v$archived_log;
alter system archive log current;

可以看出在归档当前重做日志后从v$archived_log中能查到当前被归档的重做日志,由于没有重启数据库,所以归档日志的文件格式仍然是默认的格式。
注:
<
alter system switch logfile 是强制日志切换,不一定就归档当前的重做日志文件(若自动归档打开,就归档前的重做日志,若自动归档没有打开,就不归档当前重做日志。)
alter system archive log current 是归档当前的重做日志文件,不管自动归档有没有打都归档。
主要的区别在于:
alter system switch logfile 对单实例数据库或RAC中的当前实例执行日志切换;
alter system archive log current 会对数据库中的所有实例执行日志切换。
>
2.9 重启数据库
shutdown immediate;
startup

2.10 查询归档信息
archive log list;

数据库由非归档模式更改为归档模式
3、归档模式的数据库更改为非归档模式
数据库从非归档模式更改为归档模式需要数据库处于mount状态下。
以下操作适用于oracle10g以上版本,对于oracle8i和9i不适用。
3.1
关闭数据库
如果数据库处于打开状态则需要先关闭数据库,如果数据库处于关闭状态,则直接执行3.2步即可。
关闭数据库之前归档当前重做日志
alter system archive log current;
shutdown immediate;

3.2 启动数据库到mount状态
startup mount;

3.3 查看的数据库的归档信息
archive log list;
或者
select name, log_mode from v$database;

3.4 更改归档模式为非归档模式
alter database noarchivelog;

3.4 查看的数据库的归档信息
archive log list;
或者
select name, log_mode from v$database;

3.5 打开数据库
alter database open;

数据库由归档模式更改为非归档模式