In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what are the parts of Oracle data block format". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the parts of Oracle block format"?
Data block structure
Oracle blocks have three parts:
Cache layer
Transaction layer
Data layer
The structure diagram of Oracle Data Block is as follows, in which the parts from Data header to Row Data are called Data Layer:
-
-Cache Layer-
-
-Transaction Layer-
-
-Data Header-
-
-Table Directory-
-
-Row Directory-
-
-Free Space-
-
-Row Data-
-
-Tailchk-
-
The following will use the bbed tool to display the relevant structural information
BBED > map File: / u01/app/oracle/oradata/shardcat/users01.dbf (7) Block: 135Dba:0x01c00087--- KTB Data Block (Table/Cluster) struct kcbh 20 bytes @ 0 struct ktbbh, 72 bytes @ 20 struct kdbh, 14 bytes @ 100 struct kdbt [1] 4 bytes @ 114 sb2 kdbr [8] @ 118ub1 freespace [7983] @ 134ub1 rowdata [71] @ 8117 ub4 tailchk @ 8188
Block component
Oracle data block three-tier C structure, which is mapped to the data block in SGA kcbh (kernel cache data block header). Cache Layer contains information about block formats, types (data, indexes, headers, etc.) and sequence data.
BBED > p kcbhstruct kcbh 20 bytes @ 0 ub1 type_kcbh @ 0 0x06 ub1 frmt_kcbh @ 1 0xa2 ub2 wrp2_kcbh @ 2 0x0000 ub4 rdba_kcbh @ 4 0x01c00087 ub4 bas_kcbh @ 8 0x01286184 ub2 wrp_kcbh @ 12 0x0000 ub1 seq_kcbh @ 14 0x01 ub1 flg_kcbh @ 15 0x06 (KCBHFDLC KCBHFCKV) ub2 chkval_kcbh @ 16 0x0137 ub2 spare3_kcbh @ 18 0x0000
The first part of the Cache Layer:Block, which is 20 bytes long, has an internal data structure called kcbh, including
Type_kcbh: block type (table/index,rollback segment,temporary segment, etc.)
Frmt_kcbh: block format (v6memv7pencev8)
Rdba_kcbh: block address DBA
Bas_kcbh/wrp_kcbh:SCN
Seq_kcbh: serial number of the block
Flg_kcbh: flag of the block
The transaction layer stores transaction information about data blocks.
Transaction Layer: the internal structure name is ktbbh. It is divided into two parts. the first part is of fixed length, 24 bytes in length, and contains some basic information related to the transaction. The second part is variable length, including itl, the length varies according to the number of itl entries, each itl length is 24 bytes, the internal structure name is ktbbhitl.
BBED > p ktbbhstruct ktbbh, 72 bytes @ 20 ub1 ktbbhtyp @ 20 0x01 (KDDBTDATA) union ktbbhsid, 4 bytes @ 24 ub4 ktbbhsg1 @ 24 0x0001af27 ub4 ktbbhod1 @ 24 0x0001af27 struct ktbbhcsc 8 bytes @ 28 ub4 kscnbas @ 28 0x01286182 ub2 kscnwrp @ 32 0x8000 ub2 kscnwrp2 @ 34 0x0000 sb2 ktbbhict @ 36 7938 ub1 ktbbhflg @ 38 0x32 (NONE) ub1 ktbbhfsl @ 39 0x00 ub4 ktbbhfnx @ 40 0x01c00080 struct ktbbhitl [0] 24 bytes @ 44 struct ktbitxid, 8 bytes @ 44 ub2 kxidusn @ 44 0x0006 ub2 kxidslt @ 46 0x0012 ub4 kxidsqn @ 48 0x000038f6 struct ktbituba 8 bytes @ 52 ub4 kubadba @ 52 0x010002d9 ub2 kubaseq @ 56 0x10c9 ub1 kubarec @ 58 0x09 ub2 ktbitflg @ 60 0x8000 (KTBFCOM) union _ ktbitun 2 bytes @ 62 sb2 _ ktbitfsc @ 62-32768 ub2 _ ktbitwrp @ 62 0x8000 ub4 ktbitbas @ 64 0x01228dbb struct ktbbhitl [1], 24 bytes @ 68 struct ktbitxid 8 bytes @ 68 ub2 kxidusn @ 68 0x0008 ub2 kxidslt @ 70 0x001b ub4 kxidsqn @ 72 0x00003a9a struct ktbituba 8 bytes @ 76 ub4 kubadba @ 76 0x010002b5 ub2 kubaseq @ 80 0x114f ub1 kubarec @ 82 0x20 ub2 ktbitflg @ 84 0x2001 (KTBFUPB) union _ ktbitun 2 bytes @ 86 sb2 _ ktbitfsc @ 86 10 ub2 _ ktbitwrp @ 86 0x000a ub4 ktbitbas @ 88 0x01286184
This structure appears at the beginning of each data block in the database. It even appears in sorted blocks that are not changed by redo. It also appears at the beginning of the data file header block and the control file header block. The cache layer provides the scale for bad data. It is also used to ensure that the correct data block is read and that the data block is not broken or damaged. The so-called broken data block is that only part of the data block is written to disk, and part of the data block retains the previous version.
Data Layer: including Data Header,Table Directory,Row Directory,Free Space and Row Data.
Data Header: length 14 bytes, internal data structure name kdbh
BBED > p kdbhstruct kdbh 14 bytes @ 100 ub1 kdbhflag @ 100 0x00 (NONE) sb1 kdbhntab @ 101 1 sb2 kdbhnrow @ 102 8 sb2 kdbhfrre @ 104-1 sb2 kdbhfsbo @ 106 34 sb2 kdbhfseo @ 108 8017 sb2 kdbhavsp @ 110 7977 sb2 kdbhtosp @ 112 7989
Where kdbhnrow is the number of records stored in the data block is 8, and there are indeed 8 records in the table. (you can tell from ROWID)
SQL > select dbms_rowid.rowid_block_number (rowid), t1.taccouniddiary t1.troomname from jy.t1 DBMS_ROWID.ROWID_BLOCK_NUMBER (ROWID) T_ID name 134 9 YYL 135 1 A 135 2 B 135 3 C 135 4 D 135 5 E 135 6 F 135 7 JYHY 135 8 JYYYL9 rows selected.
Table Directory: generally, table has only one entry, while cluster has one or more entries. Each entry is 4 bytes long and the internal data structure name is kdbt
BBED > p kdbtstruct kdbt [0], 4 bytes @ 114 sb2 kdbtoffs @ 1140 sb2 kdbtnrow @ 1168
Row Directory: the number is determined by the number of rows of data in the block. Each entry is 2 bytes long. The internal data structure name is kdbr.
BBED > p kdbrsb2 kdbr [0] @ 118 8080sb2 kdbr [1] @ 120 8072sb2 kdbr [2] @ 122 8064sb2 kdbr [3] @ 124 8056sb2 kdbr [4] @ 126 8048sb2 kdbr [5] @ 128 8040sb2 kdbr [6] @ 130 8029sb2 kdbr [7] @ 132 8017
Looking at the record data in the table, a repeat count can also be specified to repeat the examine command to check subsequent row records. The following example shows using the print command to set the offset of the last row of records, and then check the operation of the next 8 lines of records.
BBED > p * kdbr [7] rowdata [0]-ub1 rowdata [0] @ 8117 0x2cBBED > x / 8rncrowdata [0] @ 8117-flag@8117: 0x2c (KDRHFL, KDRHFF) KDRHFH) lock@8118: 0x02cols@8119: 2col 0 [2] @ 8120: 8col 1 [5] @ 8123: JYYYLrowdata [12] @ 8129-flag@8129: 0x2c (KDRHFL, KDRHFF) KDRHFH) lock@8130: 0x00cols@8131: 2col 0 [2] @ 8132: 7col 1 [4] @ 8135: JYHYrowdata [23] @ 8140-flag@8140: 0x2c (KDRHFL, KDRHFF) KDRHFH) lock@8141: 0x00cols@8142: 2col 0 [2] @ 8143: 6col 1 [1] @ 8146: Frowdata [31] @ 8148-flag@8148: 0x2c (KDRHFL, KDRHFF) KDRHFH) lock@8149: 0x00cols@8150: 2col 0 [2] @ 8151: 5col 1 [1] @ 8154: Erowdata [39] @ 8156-flag@8156: 0x2c (KDRHFL, KDRHFF) KDRHFH) lock@8157: 0x00cols@8158: 2col 0 [2] @ 8159: 4col 1 [1] @ 8162: Drowdata [47] @ 8164-flag@8164: 0x2c (KDRHFL, KDRHFF) KDRHFH) lock@8165: 0x00cols@8166: 2col 0 [2] @ 8167: 3col 1 [1] @ 8170: Crowdata [55] @ 8172-flag@8172: 0x2c (KDRHFL, KDRHFF) KDRHFH) lock@8173: 0x00cols@8174: 2col 0 [2] @ 8175: 2col 1 [1] @ 8178: Browdata [63] @ 8180-flag@8180: 0x2c (KDRHFL, KDRHFF, KDRHFH) lock@8181: 0x00cols@8182: 2col 0 [2] @ 8183: 1col 1 [1] @ 8186: a
Free Space: indicates the available space in the data block. The internal data structure name is freespace.
Row Data: represents the actual data, internal data structure name rowdata
BBED > p rowdata [0] ub1 rowdata [0] @ 8117 0x2cBBED > d / v offset 8117 File: / u01/app/oracle/oradata/shardcat/users01.dbf (7) Block: 135Offsets: 8117 to 8191 Dba:0x01c00087--- 2c020202 c109054a 5959594c 2c000202 l .JYYYL,... C108044a 5948592c 000202c1 0701462c l... JYHY,.F, 000202c1 0601452c 000202c1 0501442c l .E, .D, 000202c1 0401432c 000202c1 0301422c l .C, .B, 000202c1 02014101 068461 l .A...a
Tailchk: data stored at the end of the block for verification, 4 bytes in length, with the internal structure name tailchk. The last four bytes of all Oracle blocks are tail check (end check).
For a tail of a block above Oracle 8, it consists of the contents of the low two bytes of SCN base, the type of the block and the SCN sequence number. For example, if the SCN base is 0x01286184 and the block type is 0x06 and the SCN serial number is 0x01, then tail check will be 0x61840601
BBED > p tailchkub4 tailchk @ 8188 0x61840601BBED > p kcbhstruct kcbh 20 bytes @ 0 ub1 type_kcbh @ 0 0x06 ub1 frmt_kcbh @ 1 0xa2 ub2 wrp2_kcbh @ 2 0x0000 ub4 rdba_kcbh @ 4 0x01c00087 ub4 bas_kcbh @ 8 0x01286184 ub2 wrp_kcbh @ 12 0x0000 ub1 seq_kcbh @ 14 0x01 ub1 flg_kcbh @ 15 0x06 (KCBHFDLC KCBHFCKV) ub2 chkval_kcbh @ 16 0x0137 ub2 spare3_kcbh @ 18 0x0000
Although the value of tail check is usually made up of these three components, Oracle stores the final value as a value (4 bytes) as a single unsigned integer. In small byte order encoding (little-endian) architecture machines, such as Intel, this value will be stored in a low-order byte-first manner. So if you use the standard block editor or the dump command to check the tail check of a block, the byte order may be different. A tail check is 0x61840601, which will be stored on disk in the form of "01068461" on the Intel machine.
BBED > dump / v offset 8188 File: / u01/app/oracle/oradata/shardcat/users01.dbf (7) Block: 135Offsets: 8188 to 8191 Dba:0x01c00087--- 01068461 l... a so far I believe that you have a deeper understanding of "what are the parts of Oracle block format?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.