一、什么是REDO LOG
REDOLOG文件是十分重要的文件,它记录了Oracle的所有变化,是数据库实例恢复机制中最为关键的组成部分。
sys@OCM> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- -------------- ------------ --------------
1 1 49 52428800 512 1 YES INACTIVE 2701394 09-3 -13 2711001 09-3 -13
2 1 50 52428800 512 1 YES INACTIVE 2711001 09-3 -13 2732482 10-3 -13
3 1 51 52428800 512 1 NO CURRENT 2732482 10-3 -13 2.8147E+14
sys@OCM> col member for a50 sys@OCM> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
3 ONLINE /u01/app/oracle/oradata/ocm/redo03.log NO
2 ONLINE /u01/app/oracle/oradata/ocm/redo02.log NO
1 ONLINE /u01/app/oracle/oradata/ocm/redo01.log NO
二、REDO LOG的作用
1、记录ORACLE数据库的变化
2、可以避免数据提交后直接写入数据文件
3、实例恢复和介质恢复
三、REDO LOG的块
1、块的大小
(1)dbfsize redo01.log
(2)SELECT DISTINCT BLOCK_SIZE FROM V$ARCHIVED_LOG;
(3)SELECT MAX(LEBSZ) FROM X$KCCLE;
(4)日志文件头的内容
ALTER SESSION SET EVENTS 'immediate trace name redohdr level 10';
2、REDO的内容
(1)改变矢量(Change Vector)
(2)重做记录(Redo Record)
(3)一条插入的产生的日志
create table t5(id int,name varchar2(100));
select max(ktuxescnw * power(2,32)+ktuxescnb) from x$ktuxe;--[K]ernel [T]ransaction [U]ndo Transa[x]tion Entry
insert into t5 values(1,'AAAAAA');
commit;
select max(ktuxescnw * power(2,32)+ktuxescnb) from x$ktuxe;
alter system dump logfile '/u01/app/oracle/oradata/ocp/redo02.log' scn min 1694394 scn max 1693357;