사용자가 DML을 수행하게 되면(즉 트랜잭션을 수행하게 되면) 오라클은 내부적으로 다음과 같은 순서로 작업을 진행한다.
SCOTT@GHLEE > create table undo_test (c1 number, c2 varchar2(10), c3 char(20));
SCOTT@GHLEE > insert into undo_test values(1, 'A', 'a');
SCOTT@GHLEE > insert into undo_test values(2, 'B', 'b');
SCOTT@GHLEE >commit;
--SID 확인
SCOTT@GHLEE >select sid from v$mystat where rownum=1;
SID
----------
1051
--rowid확인
SCOTT@GHLEE >select rowid, substr(rowid, 1, 15), c1 from undo_test;
ROWID SUBSTR(ROWID,1,15) C1
----------------------------------------------------------
AAAOYKAAdAAAAkKAAA AAAOYKAAdAAAAkK 1
AAAOYKAAdAAAAkKAAB AAAOYKAAdAAAAkK 2
--Dump수행을 위한 File#, Block#추출
SCOTT@GHLEE >var v_rowid_type number;
SCOTT@GHLEE >var v_object_number number;
SCOTT@GHLEE >var v_relative_fno number;
SCOTT@GHLEE >var v_block_number number;
SCOTT@GHLEE >var v_row_number number;
SCOTT@GHLEE >set serveroutput on
SCOTT@GHLEE >exec dbms_rowid.rowid_info ('&1', :v_rowid_type, :v_object_number, :v_relative_fno, :v_block_number,:v_row_number);
1의 값을 입력하십시오: AAAOYKAAdAAAAkKAAA
SCOTT@GHLEE >print v_relative_fno
V_RELATIVE_FNO
--------------
29
SCOTT@GHLEE >print v_block_number
V_BLOCK_NUMBER
--------------
2314
SCOTT@GHLEE >delete from undo_test;
--테스트 1단계 커밋 수행 전 데이터 블록 덤프
SYS@GHLEE >alter system dump datafile 29 block 2314;
SYS@GHLEE >select xidusn, xidslot, xidsqn
2 from v$transaction
3 where addr = (select taddr from v$session where sid = 1051);
XIDUSN XIDSLOT XIDSQN
---------- ---------- ----------
3 25 15206
--테스트 2단계 커밋 수행 전 언두 헤더 블록 덤프
SYS@GHLEE >alter system dump undo header '_SYSSMU3$';
--테스트 3단계 커밋 수행 전 언두 블록 덤프
alter system dump undo block '_SYSSMU3$' xid 3 25 15206;
--테스트 4단계 커밋 수행 후 데이터 블록 덤프
SCOTT@GHLEE >commit;
SYS@GHLEE >alter system dump datafile 29 block 2314;
--테스트 5단계 커밋 수행 전 언두 헤더 블록 덤프
SYS@GHLEE >alter system dump undo header '_SYSSMU3$';
--테스트 6단계 커밋 수행 전 언두 블록 덤프
alter system dump undo block '_SYSSMU3$' xid 3 25 15206;
Start dump data blocks tsn: 25 file#: 29 minblk 2314 maxblk 2314
buffer tsn: 25 rdba: 0x0740090a (29/2314)
scn: 0x0a27.06343f28 seq: 0x06 flg: 0x02 tail: 0x3f280606
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Object id on Block? Y
seg/obj: 0xe60b csc: 0xa27.6343f5a itc: 2 flg: O typ: 1 - DATA
fsl: 0? fnx: 0x0 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0001.021.00002f0d 0x00802e49.14a2.33 C--- 0 scn 0x0a27.06343f28
0x02 0x0003.019.00003b66 0x0080002d.14ec.0a ---- 2 fsc 0x0036.00000000
Start dump data blocks tsn: 25 file#: 29 minblk 2314 maxblk 2314
buffer tsn: 25 rdba: 0x0740090a (29/2314)
scn: 0x0a27.06343f9c seq: 0x01 flg: 0x02 tail: 0x3f9c0601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x0740090a
Object id on Block? Y
seg/obj: 0xe60b csc: 0xa27.6343f5a itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x0 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0001.021.00002f0d 0x00802e49.14a2.33 C--- 0 scn 0x0a27.06343f28
0x02 0x0003.019.00003b66 0x0080002d.14ec.0a --U- 2 fsc 0x0036.06343f9c
********************************************************************************
Undo Segment: _SYSSMU3$ (3)
********************************************************************************
TRN TBL::
index state cflags wrap# uel scn dba parent-xid nub stmt_num cmt
------------------------------------------------------------------------------------------------
...
0x18 9 0x00 0x3b8b 0x0011 0x0a27.06343daa 0x0080002b 0x0000.000.00000000 0x00000001 0x00000000 1256068612
0x19 10 0x80 0x3b66 0x0000 0x0a27.06343f28 0x0080002d 0x0000.000.00000000 0x00000001 0x00000000 0
0x1a 9 0x00 0x3b69 0x0002 0x0a27.06343e94 0x0080002b 0x0000.000.00000000 0x00000001 0x00000000 1256068912
....
********************************************************************************
Undo Segment: _SYSSMU3$ (3)
********************************************************************************
TRN TBL::
index state cflags wrap# uel scn dba parent-xid nub stmt_num cmt
------------------------------------------------------------------------------------------------
...
0x18 9 0x00 0x3b8b 0x0011 0x0a27.06343daa 0x0080002b 0x0000.000.00000000 0x00000001 0x00000000 1256068612
0x19 9 0x00 0x3b66 0xffff 0x0a27.06343f9c 0x0080002d 0x0000.000.00000000 0x00000001 0x00000000 1256069358
0x1a 9 0x00 0x3b69 0x0002 0x0a27.06343e94 0x0080002b 0x0000.000.00000000 0x00000001 0x00000000 1256068912
....
********************************************************************************
Undo Segment: _SYSSMU3$ (3)
xid: 0x0003.019.00003b66
Low Blk : (0, 0)
High Blk : (12, 127)
Object Id : ALL
Layer : ALL
Opcode : ALL
Level : 2
********************************************************************************
UNDO BLK: Extent: 0 Block: 3 dba (file#, block#): 2,0x0000002d
xid: 0x0003.019.00003b66 seq: 0x14ec cnt: 0xa irb: 0xa icl: 0x0 flg: 0x0000
*-----------------------------
* Rec #0xa slt: 0x19 objn: 58891(0x0000e60b) objd: 58891 tblspc: 25(0x00000019)
* Layer: 11 (Row) opc: 1 rci 0x09
Undo type: Regular undo Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000
*-----------------------------
*-----------------------------
* Rec #0x9 slt: 0x19 objn: 58891(0x0000e60b) objd: 58891 tblspc: 25(0x00000019)
* Layer: 11 (Row) opc: 1 rci 0x00
Undo type: Regular undo Begin trans Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000
*-----------------------------
SCOTT@GHLEE >create table undo_test1 (c1 number, c2 char(2000));
SCOTT@GHLEE >create sequence test1_sesq;
SCOTT@GHLEE >begin
2 for i in 1..1000 loop
3 insert into undo_test1 values(test1_sesq.nextval, 'c2');
4 end loop;
5 commit;
6 end;
7 /
SCOTT@GHLEE >select rowid, substr(rowid, 1, 15), c1 from undo_test1 where c1=1000;
ROWID SUBSTR(ROWID,1,15) C1
------------------ ------------------------------ ----------
AAAOZjAAdAAAArXAAA AAAOZjAAdAAAArX 1000
SCOTT@GHLEE >var v_rowid_type number;
SCOTT@GHLEE >var v_object_number number;
SCOTT@GHLEE >var v_relative_fno number;
SCOTT@GHLEE >var v_block_number number;
SCOTT@GHLEE >var v_row_number number;
SCOTT@GHLEE >set serveroutput on
SCOTT@GHLEE >exec dbms_rowid.rowid_info ('&1', :v_rowid_type, :v_object_number, :v_relative_fno, :v_block_number,:v_row_number);
1의 값을 입력하십시오: AAAOZjAAdAAAArXAAA
PL/SQL 처리가 정상적으로 완료되었습니다.
SCOTT@GHLEE >print v_relative_fno
V_RELATIVE_FNO
--------------
29
SCOTT@GHLEE >print v_block_number
V_BLOCK_NUMBER
--------------
2775
SCOTT@GHLEE >delete from undo_test1;
1000 행이 삭제되었습니다.
SYS@GHLEE >alter system dump datafile 29 block 2775;
Start dump data blocks tsn: 25 file#: 29 minblk 2775 maxblk 2775
buffer tsn: 25 rdba: 0x07400ad7 (29/2775)
scn: 0x0a27.06355c73 seq: 0x01 flg: 0x00 tail: 0x5c730601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x07400ad7
Object id on Block? Y
seg/obj: 0xe663 csc: 0xa27.6355c73 itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x7400ad8 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0001.00d.00002f2b 0x00803c99.14a5.28 C--- 0 scn 0x0a27.063559c0
0x02 0x0009.025.000032f3 0x00803ff3.137c.04 ---- 1 fsc 0x07d7.00000000
data_block_dump,data header at 0xc986e5c
===============
block_row_dump:
tab 0, row 0, @0x17c7
tl: 2 fb: --HDFL-- lb: 0x2
SYS@GHLEE >alter system flush buffer_cache;;
SCOTT@GHLEE >commit;
SYS@GHLEE >alter system dump datafile 29 block 2775;
Start dump data blocks tsn: 25 file#: 29 minblk 2775 maxblk 2775
buffer tsn: 25 rdba: 0x07400ad7 (29/2775)
scn: 0x0a27.06355c73 seq: 0x01 flg: 0x04 tail: 0x5c730601
frmt: 0x02 chkval: 0x24b3 type: 0x06=trans data
Block header dump: 0x07400ad7
Object id on Block? Y
seg/obj: 0xe663 csc: 0xa27.6355c73 itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x7400ad8 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0001.00d.00002f2b 0x00803c99.14a5.28 C--- 0 scn 0x0a27.063559c0
0x02 0x0009.025.000032f3 0x00803ff3.137c.04 ---- 1 fsc 0x07d7.00000000
data_block_dump,data header at 0xc986e5c
===============
block_row_dump:
tab 0, row 0, @0x17c7
tl: 2 fb: --HDFL-- lb: 0x2
SCOTT@GHLEE >select * from undo_test1;
SYS@GHLEE >alter system dump datafile 29 block 2775;
Start dump data blocks tsn: 25 file#: 29 minblk 2775 maxblk 2775
buffer tsn: 25 rdba: 0x07400ad7 (29/2775)
scn: 0x0a27.06355c95 seq: 0x01 flg: 0x00 tail: 0x5c950601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x07400ad7
Object id on Block? Y
seg/obj: 0xe663 csc: 0xa27.6355c95 itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x7400ad8 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0001.00d.00002f2b 0x00803c99.14a5.28 C--- 0 scn 0x0a27.063559c0
0x02 0x0009.025.000032f3 0x00803ff3.137c.04 C--- 0 scn 0x0a27.06355c89
data_block_dump,data header at 0xc986e5c
===============
data_block_dump:
SCOTT@GHLEE >create table undo_test (c1 number, c2 varchar2(10), c3 char(20));
SCOTT@GHLEE >insert into undo_test values(1, 'A', 'a');
SCOTT@GHLEE >insert into undo_test values(1, 'B', 'b');
SCOTT@GHLEE >insert into undo_test values(3, 'C', 'c');
SCOTT@GHLEE >commit;
SCOTT@GHLEE >select rowid, substr(rowid, 1, 15), c1 from undo_test;
ROWID SUBSTR(ROWID,1,15) C1
------------------ ------------------------------ ----------
AAAOZiAAdAAAAkKAAA AAAOZiAAdAAAAkK 1
AAAOZiAAdAAAAkKAAB AAAOZiAAdAAAAkK 2
AAAOZiAAdAAAAkKAAC AAAOZiAAdAAAAkK 3
SCOTT@GHLEE >var v_rowid_type number;
SCOTT@GHLEE >var v_object_number number;
SCOTT@GHLEE >var v_relative_fno number;
SCOTT@GHLEE >var v_block_number number;
SCOTT@GHLEE >var v_row_number number;
SCOTT@GHLEE >set serveroutput on
SCOTT@GHLEE >exec dbms_rowid.rowid_info ('&1', :v_rowid_type, :v_object_number, :v_relative_fno, :v_block_number,:v_row_number);
1의 값을 입력하십시오: AAAOZiAAdAAAAkKAAA
SCOTT@GHLEE >print v_relative_fno
V_RELATIVE_FNO
--------------
29
SCOTT@GHLEE >print v_block_number
V_BLOCK_NUMBER
--------------
2314
SCOTT@GHLEE >delete from undo_test where c1=1;
SYS@GHLEE >alter system dump datafile 29 block 2314;
Start dump data blocks tsn: 25 file#: 29 minblk 2314 maxblk 2314
buffer tsn: 25 rdba: 0x0740090a (29/2314)
scn: 0x0a27.06355889 seq: 0x07 flg: 0x02 tail: 0x58890607
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x0740090a
Object id on Block? Y
seg/obj: 0xe662 csc: 0xa27.63558a7 itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x0 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0005.02c.000033e0 0x008039c4.1418.1d C--- 0 scn 0x0a27.06355889
0x02 0x0009.027.000032cf 0x00803da3.137a.0e ---- 1 fsc 0x001b.00000000
data_block_dump,data header at 0xc986e5c
===============
block_row_dump:
tab 0, row 0, @0x1f83
tl: 2 fb: --HDFL-- lb: 0x2
tab 0, row 1, @0x1f66
tl: 29 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [ 2] c1 03
col 1: [ 1] 42
col 2: [20] 62 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
tab 0, row 2, @0x1f49
tl: 29 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [ 2] c1 04
col 1: [ 1] 43
col 2: [20] 63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
SCOTT@GHLEE >commit;
SYS@GHLEE >alter system dump datafile 29 block 2314;
Start dump data blocks tsn: 25 file#: 29 minblk 2314 maxblk 2314
buffer tsn: 25 rdba: 0x0740090a (29/2314)
scn: 0x0a27.063558c5 seq: 0x02 flg: 0x02 tail: 0x58c50602
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x0740090a
Object id on Block? Y
seg/obj: 0xe662 csc: 0xa27.63558a7 itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x0 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0005.02c.000033e0 0x008039c4.1418.1d C--- 0 scn 0x0a27.06355889
0x02 0x0009.027.000032cf 0x00803da3.137a.0e --U- 1 fsc 0x001b.063558c5
data_block_dump,data header at 0xc986e5c
===============
block_row_dump:
tab 0, row 0, @0x1f83
tl: 2 fb: --HDFL-- lb: 0x2
tab 0, row 1, @0x1f66
tl: 29 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [ 2] c1 03
col 1: [ 1] 42
col 2: [20] 62 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
tab 0, row 2, @0x1f49
tl: 29 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [ 2] c1 04
col 1: [ 1] 43
col 2: [20] 63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
end_of_block_dump
SCOTT@GHLEE >select count(*) from undo_test;
COUNT(*)
----------
2
SYS@GHLEE >alter system dump datafile 29 block 2314;
Start dump data blocks tsn: 25 file#: 29 minblk 2314 maxblk 2314
buffer tsn: 25 rdba: 0x0740090a (29/2314)
scn: 0x0a27.063558c5 seq: 0x02 flg: 0x02 tail: 0x58c50602
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x0740090a
Object id on Block? Y
seg/obj: 0xe662 csc: 0xa27.63558a7 itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x0 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0005.02c.000033e0 0x008039c4.1418.1d C--- 0 scn 0x0a27.06355889
0x02 0x0009.027.000032cf 0x00803da3.137a.0e --U- 1 fsc 0x001b.063558c5
data_block_dump,data header at 0xc986e5c
===============
block_row_dump:
tab 0, row 0, @0x1f83
tl: 2 fb: --HDFL-- lb: 0x2
tab 0, row 1, @0x1f66
tl: 29 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [ 2] c1 03
col 1: [ 1] 42
col 2: [20] 62 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
tab 0, row 2, @0x1f49
tl: 29 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [ 2] c1 04
col 1: [ 1] 43
col 2: [20] 63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
SCOTT@GHLEE >delete from undo_test where c1=2;
SYS@GHLEE >alter system dump datafile 29 block 2314;
Start dump data blocks tsn: 25 file#: 29 minblk 2314 maxblk 2314
buffer tsn: 25 rdba: 0x0740090a (29/2314)
scn: 0x0a27.063558ea seq: 0x01 flg: 0x04 tail: 0x58ea0601
frmt: 0x02 chkval: 0x9bb6 type: 0x06=trans data
Block header dump: 0x0740090a
Object id on Block? Y
seg/obj: 0xe662 csc: 0xa27.63558a7 itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x0 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0001.00b.00002f65 0x00803c90.14a5.15 ---- 1 fsc 0x001b.00000000
0x02 0x0009.027.000032cf 0x00803da3.137a.0e --U- 1 fsc 0x001b.063558c5
data_block_dump,data header at 0xc986e5c
===============
block_row_dump:
tab 0, row 0, @0x1f83
tl: 2 fb: --HDFL-- lb: 0x2
tab 0, row 1, @0x1f66
tl: 2 fb: --HDFL-- lb: 0x1
tab 0, row 2, @0x1f49
tl: 29 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [ 2] c1 04
col 1: [ 1] 43
col 2: [20] 63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
SCOTT@GHLEE >commit;
SYS@GHLEE >alter system dump datafile 29 block 2314;
Start dump data blocks tsn: 25 file#: 29 minblk 2314 maxblk 2314
buffer tsn: 25 rdba: 0x0740090a (29/2314)
scn: 0x0a27.063558f4 seq: 0x01 flg: 0x02 tail: 0x58f40601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x0740090a
Object id on Block? Y
seg/obj: 0xe662 csc: 0xa27.63558a7 itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x0 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0001.00b.00002f65 0x00803c90.14a5.15 --U- 1 fsc 0x001b.063558f4
0x02 0x0009.027.000032cf 0x00803da3.137a.0e --U- 1 fsc 0x001b.063558c5
data_block_dump,data header at 0xc986e5c
===============
block_row_dump:
tab 0, row 0, @0x1f83
tl: 2 fb: --HDFL-- lb: 0x2
tab 0, row 1, @0x1f66
tl: 2 fb: --HDFL-- lb: 0x1
tab 0, row 2, @0x1f49
tl: 29 fb: --H-FL-- lb: 0x0 cc: 3
col 0: [ 2] c1 04
col 1: [ 1] 43
col 2: [20] 63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
SCOTT@GHLEE >delete from undo_test where c1=3;
SYS@GHLEE >alter system dump datafile 29 block 2314;
Start dump data blocks tsn: 25 file#: 29 minblk 2314 maxblk 2314
buffer tsn: 25 rdba: 0x0740090a (29/2314)
scn: 0x0a27.063558f4 seq: 0x01 flg: 0x02 tail: 0x58f40601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
Block header dump: 0x0740090a
Object id on Block? Y
seg/obj: 0xe662 csc: 0xa27.635590b itc: 2 flg: O typ: 1 - DATA
fsl: 0 fnx: 0x0 ver: 0x01
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0001.00b.00002f65 0x00803c90.14a5.15 C--- 0 scn 0x0a27.063558f4
0x02 0x0008.01e.00003181 0x00802b7e.12fc.12 ---- 1 fsc 0x001b.00000000
data_block_dump,data header at 0xc986e5c
===============
block_row_dump:
tab 0, row 2, @0x1f49
tl: 2 fb: --HDFL-- lb: 0x2
항목 | Fast block cleanout | Delayed block cleanout |
---|---|---|
대상블록 | 버퍼캐시에 존재하는 블록 | 버퍼캐시에 존재하지 않는 블록 |
Partial Cleanout 여부 | 가능 | 불가능 |
Partial Cleanout시에 변경되는 내용 | 블록 Scn# Itl의 Flag 변경(\--U-) Itl의 Scn/Fsc의 Scn Base# | N/A |
Full Cleanout이 발생하는 시점 | 해당 블록에 트랜잭션이 수행되는 시점 | 해당 블록을 디스크에서 버퍼캐시로 적재하는 시점 |
Full Cleanout시에 변경되는 내용 | Itl의 Flag 변경(C---) Itl의 Lck 초기화(0) Itl의 Scn/Fsc의 Scn Wrap# Row 레코드 정리 | 블록 Scn# Itl의 Flag 변경(C---) Itl의 Lck 초기화(0) Itl의 Scn/Fsc의 Scn Base#/Wrap# Row 레코드 정리 |