1
undo段又叫rollback段,undo的前身就是rollback,查詢undo段。
2
先查出表內容:
SQL> select * from t2;
ID NA
---------- --
1 A
2 a
3 b
4 c
SQL> update t2 set NAME=ab where id=4;
1 row updated.
3
查出該表的行數據所在的邏輯文件編號和塊編號:
SQL> select dbms_rowid.rowid_relative_fno(rowid) fno,dbms_rowid.rowid_block_number(rowid) bn1 from t2;
FNO BN1
---------- ----------
41 1519940
41 1519940
41 1519940
41 1519940
SQL> show parameter dump
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
background_core_dump string partial
background_dump_dest string /u01/app/oracle/diag/rdbms/ocs
tstdb/ocststdb/trace
core_dump_dest string /u01/app/oracle/diag/rdbms/ocs
tstdb/ocststdb/cdump
max_dump_file_size string unlimited
shadow_core_dump string partial
user_dump_dest string /u01/app/oracle/diag/rdbms/ocs
tstdb/ocststdb/trace
SQL> alter system dump datafile 41 block 1519940;
System altered.
SQL> select distinct sid from v$mystat;
SID
----------
581
SQL> select paddr from v$session where sid=581;
PADDR
----------------
0000000253FCC010
SQL> select spid from v$process where addr=0000000253FCC010;
SPID
------------------------
8212
[oracle@ocsdbtest trace]$ pwd
/u01/app/oracle/diag/rdbms/ocststdb/ocststdb/trace
[oracle@ocsdbtest trace]$ ls *8212.trc
ocststdb_ora_8212.trc
.................
Start dump data blocks tsn: 42 file#:41 minblk 1519940 maxblk 1519940
.................
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0003.017.002c083b 0x00c004f8.e3f0.06 C--- 0 scn 0x0e73.5c418bf9
0x02 0x0009.010.002c7c61 0x00c0032e.e670.23 ---- 1 fsc 0x0000.00000000
bdba: 0x0a573144
data_block_dump,data header at 0x7f0ea1953a64
===============
tsiz: 0x1f98
hsiz: 0x1a
pbl: 0x7f0ea1953a64
76543210
flag=--------
ntab=1
nrow=4
frre=-1
fsbo=0x1a
fseo=0x1f6f
avsp=0x1f5a
tosp=0x1f5a
0xe:pti[0] nrow=4 offs=0
0x12:pri[0] offs=0x1f90
0x14:pri[1] offs=0x1f88
0x16:pri[2] offs=0x1f80
0x18:pri[3] offs=0x1f6f
block_row_dump:
tab 0, row 0, @0x1f90
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 02
col 1: [ 1] 41
tab 0, row 1, @0x1f88
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 03
col 1: [ 1] 61
tab 0, row 2, @0x1f80
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 04
col 1: [ 1] 62
tab 0, row 3, @0x1f6f
tl: 9 fb: --H-FL-- lb: 0x2 cc: 2
col 0: [ 2] c1 05
col 1: [ 2] 61 62
end_of_block_dump
End dump data blocks tsn: 42 file#: 41 minblk 1519940 maxblk 1519940
4
再次dump絕對文件的內容:
SQL> alter system dump datafile /oradata/ocststdb/TSSXCPMIS01.dbf block 1519940;
System altered.
...............
Start dump data block from file /oradata/ocststdb/TSSXCPMIS01.dbf minblk 1519940 maxblk 1519940
.............
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0003.017.002c083b 0x00c00b68.6795.07 C--- 0 scn 0x0e73.5c418bf9
0x02 0x0009.010.002c7c61 0x00c00b68.6795.0b ---- 1 fsc 0x0000.00000000
bdba: 0x0a573144
data_block_dump,data header at 0x7f0ea1953a64
===============
tsiz: 0x1f98
hsiz: 0x1a
pbl: 0x7f0ea1953a64
76543210
flag=--------
ntab=1
nrow=4
frre=-1
fsbo=0x1a
fseo=0x1f6f
avsp=0x1f5a
tosp=0x1f5a
0xe:pti[0] nrow=4 offs=0
0x12:pri[0] offs=0x1f90
0x14:pri[1] offs=0x1f88
0x16:pri[2] offs=0x1f80
0x18:pri[3] offs=0x1f6f
block_row_dump:
tab 0, row 0, @0x1f90
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 02
col 1: [ 1] 41
tab 0, row 1, @0x1f88
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 03
col 1: [ 1] 61
tab 0, row 2, @0x1f80
tl: 8 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 04
col 1: [ 1] 62
tab 0, row 3, @0x1f6f
tl: 9 fb: --H-FL-- lb: 0x2 cc: 2
col 0: [ 2] c1 05
col 1: [ 2] 61 62
end_of_block_dump
End dump data block from file /oradata/ocststdb/TSSXCPMIS01.dbf minblk 1519940 maxblk 1519940
Start dump data block from file /oradata/ocststdb/TSSXCPMIS01.dbf minblk 1519940 maxblk 1519940
nrow=4
tl: 9 fb: --H-FL-- lb: 0x2 cc: 2
col 0: [ 2] c1 05
col 1: [ 2] 61 62
5
截取地址(Uba:0x00c00b68.6795.07),0x和第一個“.”之間內容,00c00b68,這是個16進制的地址,通過這個地址獲取文件編號和塊編號。
SQL> select to_number(00c00b68,xxxxxxxxxx) from dual;
TO_NUMBER(00C00B68,XXXXXXXXXX)
----------------------------------
12585832
SQL> select dbms_utility.data_block_address_file(12585832) from dual;
DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(12585832)
----------------------------------------------
3
SQL> select dbms_utility.data_block_address_block(12585832) from dual;
DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK(12585832)
-----------------------------------------------
2920
SQL> show parameter undo_tablespace
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace string UNDOTBS1
SQL> select file_id from dba_data_files where tablespace_name=UNDOTBS1;
FILE_ID
----------
3
SQL> alter system dump datafile 3 block 2920;
System altered.
*-----------------------------
* Rec #0x7 slt: 0x1a objn: 176942(0x0002b32e) objd: 176942 tblspc: 42(0x0000002a)
* Layer: 11 (Row) opc: 1 rci 0x00
Undo type: Regular undo Begin trans Last buffer split: No
Temp Object: No
Tablespace Undo: No
rdba: 0x00000000Ext idx: 0
flg2: 0
*-----------------------------
uba: 0x00c00b68.6795.06 ctl max scn: 0x0e73.5c4ac77d prv tx scn: 0x0e73.5c4ac783
txn start scn: scn: 0x0e73.5c4a9dce logon user: 130
prev brb: 12585831 prev bcl: 0
KDO undo record:
KTB Redo
op: 0x03 ver: 0x01
compat bit: 4 (post-11) padding: 1
op: Z
KDO Op code: URP row dependencies Disabled
xtype: XA flags: 0x00000000 bdba: 0x0a573144 hdba: 0x0a573142
itli: 2 ispac: 0 maxfr: 4858
tabn: 0 slot: 3(0x3) flag: 0x2c lock: 0 ckix: 0
ncol: 2 nnew: 1 size: -1
col 1: [ 1] 63
SQL> select ascii(a) from dual;
ASCII(A)
----------
97
SQL> select ascii(b) from dual;
ASCII(B)
----------
98
SQL> select to_char(97,XX) from dual;
TO_
---
61
SQL> select to_char(98,XX) from dual;
TO_
---
62
6
可以看到第一個dump文件,邏輯文件編號出來的文件,和第二個dump文件,絕對文件編號出來的文件,在最后一行的內容都是一致的:
col 1: [ 2] 61 62
7
通過dump數據得到驗證,表的邏輯數據和磁盤數據都保存的是新數據,undo段里則保存原始數據。
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/129604.html
閱讀 1346·2023-01-11 13:20
閱讀 1684·2023-01-11 13:20
閱讀 1132·2023-01-11 13:20
閱讀 1858·2023-01-11 13:20
閱讀 4100·2023-01-11 13:20
閱讀 2704·2023-01-11 13:20
閱讀 1385·2023-01-11 13:20
閱讀 3597·2023-01-11 13:20