For redo logs, the redo information is quite simplified. oracle only needs to record the information required for restructuring the transaction (such as the transaction number, file number, block number, row number, field, and so on, this data
For redo logs, the redo information is quite simplified. oracle only needs to record the information required for restructuring the transaction (such as the transaction number, file number, block number, row number, field, and so on, this data
Redo content
Oracle uses redo to implement the same fast commit. On the one hand, it is because redo log files can be written continuously and sequentially. On the other hand
It is also related to the simplified content of the redo record.
To understand the redo content, you must first understand two concepts: Change vectors and redo records.
Change vector)
The change vector indicates a change made to a data block in the database. The change vector contains the changed data.
The version number of the block, the transaction operation code, the address of the changed slave data block (DBA), and the updated data. For example, an update transaction contains
A series of change vectors, the modification to the data block is a vector, and the modification to the rollback segment is a vector.
Redo record)
Redo records are usually composed of a set of change vectors. They are a set of change vectors, representing changes to a database (insert, update, delete ).
The minimum recovery unit for database changes. For example, an update redo record includes the change vectors of the corresponding rollback segments and the corresponding
The Change vector of the data block.
Assume that an update statement is issued;
Update scott. emp set sal = 4000 where empno = 7788;
Let's see how this statement is executed.
1. Check whether the empno = 7788 record exists in the buffer cache. If it does not exist, it is read to the buffer cache.
2. Allocate transaction slots in the corresponding rollback segment of the rollback tablespace transaction table. This operation requires redo information to be recorded.
3. Read from the rollback segment or create a prefix image with sal = 3000 in the buffer cache, which generates redo information and records it in the redo log buffer.
4. Modify sal = 4000. This is the update data change and must be recorded in the redo log buffer.
5. When the user commits the transaction, the commit information is recorded in the redo log buffer, and the transaction is marked as Inactive in the rollback segment)
The following describes how to reproduce the process through a specific test on Jane.
1. switch logfile to switch logs and use sys to switch logs so that new logs can be used for subsequent updates.
SQL> alter system switch logfile;
System altered.
SQL> select * from v $ log;
GROUP # THREAD # SEQUENCE # BYTES MEMBERS ARC STATUS
---------------------------------------------------------------------
FIRST_CHANGE # FIRST_TIME
-------------------------
1 1 14 52428800 1 NO ACTIVE
801067 03-JAN-14
2 1 15 52428800 1 NO CURRENT
813289 04-JAN-13
3 1 13 52428800 1 NO INACTIVE
764715 30-DEC-13
2. Update and submit the transaction
SQL> select * from scott. emp a where a. empno = 7788;
EMPNO ENAME JOB MGR HIREDATE SAL COMM
-----------------------------------------------------------------------
DEPTNO
----------
7788 scott analyst 7566 19-APR-87 3000
20
SQL & gt; update scott. emp set sal = 4000 where empno = 7788;
1 row updated.
SQL> commit;
Commit complete.
3. Use the sys user to dump the log file in another session:
SQL> alter system dump logfile '/u01/app/oracle/product/10.2.0/oradata/jingyong/redo02.log ';
System altered.
SQL> select
2 d. value | '/' | lower (rtrim (I. instance,
3 chr (0) | '_ ora _' | p. spid | '. trc' trace_file_name
4 from (select p. spid
5 from sys. v $ mystat m,
6 sys. v $ session s, sys. v $ process p
7 where m. statistic # = 1 and s. sid = m. sid and p. addr = s. paddr) p,
8 (select t. instance from sys. v $ thread t, sys. v $ parameter v
9 where v. name = 'thread' and
10 (v. value = 0 or t. thread # = to_number (v. value) I,
11 (select value from sys. v $ parameter
12 where name = 'user _ dump_dest ') d
13/
TRACE_FILE_NAME
--------------------------------------------------------------------------------
/U01/app/oracle/admin/jingyong/udump/jingyong_ora_assist.trc
,