《Undo, Redo, DataFile看Oracle中的事務過程》學習筆記
1:提交當前session中的pending
transaction,
SQL> show autocommit;
autocommit OFF
SQL> commit;
Commit complete.
2:確定transaction前的scn,
SQL> conn /as
sysdba
SQL> select
max(KTUXESCNW*power(2,32)+KTUXESCNB) from x$ktuxe;
MAX(KTUXESCNW*POWER(2,32)+KTUXESCNB)
------------------------------------
3723460
3:資料更新
SQL> conn
scott/tiger
Connected.
SQL> select
object_name,object_id from emp where rownum<2;
OBJECT_NAME OBJECT_ID
------------------------------
----------
/1005bd30_LnkdConstant 17945
SQL> update emp
set object_name='abc' where
object_id=17945;
1 row updated.
4:檢視剛剛操作的transaction及回滾段資訊
SQL> select
xidusn,xidslot,xidsqn,ubafil,ubablk,ubasqn,ubarec
2 from
v$transaction;
XIDUSN
XIDSLOT XIDSQN UBAFIL
UBABLK UBASQN UBAREC
---------- ----------
---------- ---------- ---------- ---------- ----------
9 14 286 2 196 44 16
SQL> select
usn,name from v$rollname where usn=9;
USN NAME
----------
------------------------------
9 _SYSSMU9$
5:Dump回滾段的頭資訊及塊資訊
SQL> alter system
dump undo header '_SYSSMU9$';
System altered.
SQL>
nodepad d:oracleadminorcludumporcl_ora_1572.trc
Dump file d:oracleadminorcludumporcl_ora_1572.trc
Wed Jul 24 15:31:47 2013
ORACLE V9.2.0.8.0 - Production vsnsta=0
vsnsql=12 vsnxtr=3
Windows 2000 Version 5.2 Service Pack 2, CPU type 586
Oracle9i Enterprise Edition Release 9.2.0.8.0 -
Production
With the Partitioning, OLAP and Oracle Data Mining
options
JServer Release 9.2.0.8.0 - Production
Windows 2000 Version 5.2 Service Pack 2, CPU type 586
Instance name: orcl
Redo thread mounted by this instance: 1
Oracle process number: 10
Windows thread id: 1572, image: ORACLE.EXE
*** 2013-07-24 15:31:47.296
*** SESSION ID:(7.3) 2013-07-24 15:31:47.234
********************************************************************************
Undo Segment:
_SYSSMU9$ (9)
********************************************************************************
Extent Control
Header
-----------------------------------------------------------------
Extent
Header:: spare1: 0 spare2: 0 #extents: 3 #blocks: 32
last map 0x00000000 #maps: 0
offset: 3056
Highwater:: 0x008000c4 ext#: 0
blk#: 8 ext size: 10
#blocks in
seg. hdr's freelists: 0
#blocks below:
0
mapblk 0x00000000
offset: 0
Unlocked
Map
Header:: next 0x00000000 #extents: 3
obj#: 0 flag: 0x40000000
Extent Map
-----------------------------------------------------------------
0x008000bc length: 10
0x008000fd length: 11
0x008000c6 length: 11
Retention Table
-----------------------------------------------------------
Extent
Number:0 Commit Time: 1364994629
Extent
Number:1 Commit Time: 0
Extent Number:2 Commit Time: 1366863357
TRN CTL:: seq:
0x002c chd: 0x0003 ctl: 0x001d inc: 0x00000000 nfb: 0x0000
mgc:
0x8201 xts: 0x0068 flg: 0x0001 opt: 2147483646 (0x7ffffffe)
uba:
0x008000c4.002c.10 scn: 0x0000.003507e6
Version: 0x01
FREE BLOCK
POOL::
uba: 0x00000000.002c.0f ext: 0x0 spc: 0x119c
uba:
0x00000000.0024.22 ext: 0x24 spc: 0x9ba
uba:
0x00000000.0024.11 ext: 0x24 spc: 0x1158
uba:
0x00000000.0000.00 ext: 0x0 spc:
0x0
uba:
0x00000000.0000.00 ext: 0x0 spc:
0x0
TRN TBL::
index state
cflags wrap# uel
scn dba parent-xid nub
stmt_num
------------------------------------------------------------------------------------------------
0x00 9
0x00 0x011e 0x0005
0x0000.003883c5 0x008000c4 0x0000.000.00000000 0x00000001
0x00000000
。。。。。。
0x0e 10
0x80 0x011e 0x0000
0x0000.0038d0f5 0x008000c4 0x0000.000.00000000 0x00000001
0x00000000
0x0f 9
0x00 0x011e 0x0006
0x0000.00385458 0x008000be 0x0000.000.00000000 0x00000001
0x00000000
0x10 9
0x00 0x011e 0x001e
0x0000.00384d47 0x008000be 0x0000.000.00000000 0x00000001
0x00000000
。。。。。。
0x22 9
0x00 0x011d 0x0010
0x0000.00384aec 0x008000be 0x0000.000.00000000 0x00000001
0x00000000
0x22-->34 共35個事務槽。 第15個事務槽state=10 表明是活動的
cflags = 0x80
-->128
wrap# = 0x011e
scn = 0x0000.0038d0f5 --> 3723509 scn is 3723460 befor update
dba = 0x008000c4 --> 00c4=196 這個是不是指的emp更新資料的資料塊兒的地址?No! file#=8 block#=196
parent-xid = 0x0000.000.00000000
在另外一篇文章中,此處的DBA被解釋為回滾塊的地址,如下:
dba:為回滾塊的地址,根據這個地址,我們可以計算出file#及block#
比如: 0x0080055f --> 055f=1375
0000 0000 10 00 0000 0000
0101 0101 1111
--------------------- ------------------------------------
file#2 block#1375
當然這個值可以不用計算,transaction的ubafil,ubablk分別為file#, block#。
0080怎麼就換算成了UBAFIL file# 2 ?後四位055f可以和UBABLK對應上。
猜想: 0080
--> 0000 0000 10 00 0000 --> 10 --> 2
答: 0x0080055f --〉0x008000c4 轉換成 10進位制8388804,
然後使用dbms_utility.data_block_address_block
dbms_utility.data_block_address_file兩個函式轉換出檔案號和塊號
下面還有敘述。
SQL> col file_name for a40
SQL> l
1* select file_id,file_name,relative_fno from dba_data_files
SQL> /
FILE_ID FILE_NAME RELATIVE_FNO
---------- ---------------------------------------- ------------
1 D:ORACLEORADATAORCLSYSTEM01.DBF 1
2
D:ORACLEORADATAORCLUNDOTBS01.DBF 2
3 D:ORACLEORADATAORCLDRSYS01.DBF 3
4 D:ORACLEORADATAORCLINDX01.DBF 4
5 D:ORACLEORADATAORCLTOOLS01.DBF 5
6 D:ORACLEORADATAORCLUSERS01.DBF 6
7 D:ORACLEORADATAORCLXDB01.DBF 7
8 D:ORACLEORADATAORCLUSR02.DBF 8
8 rows selected.
update emp set object_name='abc' where object_id=17945;
這行資料所在的file# block#是什麼呢?
參考內容:
2.1 Find the DBA for a given row
Start by getting the file and block number of the row.
Example:
SQL> SELECT
2 dbms_rowid.rowid_relative_fno(rowid)
REL_FNO,
3 dbms_rowid.rowid_block_number(rowid)
BLOCKNO,
4 empno, ename
5 FROM emp WHERE empno = 7369;
REL_FNO BLOCKNO
EMPNO ENAME
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/271063/viewspace-1060778/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【REDO】Oracle redo undo 學習Oracle Redo
- 淺析MySQL事務中的redo與undoMySql
- Oracle Redo and UndoOracle Redo
- oracle的redo和undoOracle
- 學習C過程中的筆記系列-2筆記
- 25_解密Oracle redo生成過程解密Oracle Redo
- MySQL中的redo log和undo logMySql
- 隨機過程學習筆記——概論隨機筆記
- [高效能MYSQL學習筆記]事務MySql筆記
- SAP Commerce Cloud 的構建過程學習筆記Cloud筆記
- MySQL 學習筆記(一)MySQL 事務的ACID特性MySql筆記
- Spring學習筆記3(JDBC模板&事務管理)Spring筆記JDBC
- MySQL事務學習筆記(一) 初遇篇MySql筆記
- Spring 事務學習筆記(一) 初遇篇Spring筆記
- MySQL事務學習筆記(三) 甚歡篇MySql筆記
- MySQL事務學習筆記(二) 相識篇MySql筆記
- oracle學習筆記《一》Oracle筆記
- Android學習過程的Cursor遊標填坑筆記Android筆記
- Java學習筆記3事務的四大特性Java筆記
- ORACLE事務和例項恢復過程梳理Oracle
- oracle 中的事務Oracle
- golang學習筆記(二)—— 深入golang中的協程Golang筆記
- 「馬爾可夫決策過程」學習筆記馬爾可夫筆記
- 隨機過程複習筆記隨機筆記
- undo log和redo log
- 28、undo_1_2(undo引數、undo段、事務)
- lua課程學習筆記筆記
- 關於oracle中的undoOracle
- 學習筆記 - 微服務筆記微服務
- Oracle學習筆記(6)——函式Oracle筆記函式
- 深入理解MYSQL undo redoMySql
- SQLServer的檢查點、redo和undoSQLServer
- 達內課程學習筆記筆記
- 機器學習課程筆記機器學習筆記
- 中斷的學習筆記筆記
- Android學習筆記14-從原始碼分析Toast的建立過程Android筆記原始碼AST
- 資料庫學習筆記:事務的特性和隔離級別資料庫筆記
- oracle之 redo過高診斷Oracle
- Spring事務筆記Spring筆記