标签:
--版本信息
SELECT * FROM v$version;
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for 32-bit Windows: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
--查看是否归档
select name,log_mode from v$database;
1 ORCL NOARCHIVELOG
或sqlplus:ARCHIVE LOG LIST;
--创建查看产生redo大小的视图
create or replace view redo_size as
select value
from v$mystat, v$statname
where v$mystat.statistic# = v$statname.statistic#
and v$statname.name = ‘redo size‘;
1.在非归档模式下:
--!!!!!!!!!!!非归档模式 产生的redo!!!!!!!!!!!!!!!!!!
--==============nologging表================
SELECT * FROM sys.redo_size;
--redo_size:0
create table test_nolog nologging as select * from dba_objects where 1=0;
--redo_size:17932
insert into test_nolog select * from dba_objects;
--redo_size:5772780
insert /*+ APPEND */ into test_nolog select * from dba_objects;
--redo_size:5782548
select (5782548-5772780) redo_append, (5772780-17932) redo_normal from dual;
9768 5754848
--================logging============================
--redo_size:11778596
create table test_log as select * from dba_objects where 1=0;
--redo_size:11799284
insert into test_log select * from dba_objects;
--redo_size:17555812
insert /*+ APPEND */ into test_log select * from dba_objects;
--redo_size:17565544
select (17565544-17555812) redo_append, (17555812-11799284) redo_normal from dual;
9732 5756528
结论:非归档模式下,只需append就能大量减少redo的产生,如果不加append,即使是nologing表也会产生一样多的redo;
2.在归档模式下:
--修改为归档模式
set ORACLE_SID=ORCL
sqlplus / as sysdba
SYS@ORCL> archive log list
数据库日志模式 非存档模式
自动存档 禁用
存档终点 USE_DB_RECOVERY_FILE_DEST
最早的联机日志序列 544
当前日志序列 546
SYS@ORCL> select log_mode from v$database;
LOG_MODE
------------
NOARCHIVELOG
SYS@ORCL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SYS@ORCL> startup mount
ORACLE 例程已经启动。
Total System Global Area 1258291200 bytes
Fixed Size 1304848 bytes
Variable Size 201328368 bytes
Database Buffers 1048576000 bytes
Redo Buffers 7081984 bytes
数据库装载完毕。
SYS@ORCL> alter database ARCHIVELOG;
数据库已更改。
SYS@ORCL> archive log list
数据库日志模式 存档模式
自动存档 启用
存档终点 USE_DB_RECOVERY_FILE_DEST
最早的联机日志序列 544
下一个存档日志序列 546
当前日志序列 546
SYS@ORCL> alter database open;
数据库已更改。
--!!!!!!!!!!!归档模式 产生的redo!!!!!!!!!!!!!!!!!!
--==============nologging表================
SELECT * FROM redo_size;
--redo_size:0
insert into test_nolog select * from dba_objects;
--redo_size:5729772
insert /*+ APPEND */ into test_nolog select * from dba_objects;
--redo_size:5739436
select (5739436-5729772) redo_append, (5729772-0) redo_normal from dual;
9664 5729772
--================loging============================
--redo_size:5729772
insert into test_log select * from dba_objects;
--redo_size:11355620
insert /*+ APPEND */ into test_log select * from dba_objects;
--redo_size:17123736
select (17123736-11355620) redo_append, (11355620-5729772) redo_normal from dual;
5768116 5625848
结论:归档模式下,append并且表为nologging 才能减少redo的产生,其余情况没效果;
标签:
原文地址:http://www.cnblogs.com/willspring/p/5756329.html