same. Hence, index,data or clustered data are contained in the same structured block.]
Block overhead = block header (general information of the block --> i. block address ii. Type of segment
Index/Data etc..)
+ table directory (contains information about the table having rows in this block)
+ row directory (actual row info [includes each row piece address in the row data
area])
[NOTE: 1.Space once allocated in the row directory for a row is a DATA BLOCK’s OVERHEAD, this space is
not reclaimed when the row is deleted.
2. A block that is currently empty but had 50 rows at a time continues to have 100 bytes
allocated in the header for the row directory.
3. Oracle reuses this space only when rows are inserted in the block.]
Row Data -- ---> contains the actual data pertaining to table or index.
Free Space ---->(i) allocated for insertion of new rows and for updates to rows that require additional
space [ for example, when a trailing null is updated to a non null values ].
(ii) also holds transaction entries. A transaction entry is required in a block for each
INSERT,DELETE,UPDATE and SELECT …. FOR UPDATE statement accessing one or more rows in the block.
Space [ for transaction entry ] --- OS dependent --- approximately 23 bytes.
The in-segment free/used space is tracked using bitmaps, as opposed to free lists.
The free space management that is done with the aid of bitmaps is AUTOMATIC free space management.
1. When an insert or update statement attempts to use a block that contains enough space to
accommodate the new row piece or data.
2. The free space is fragmented so the new row piece cannot be accommodated in a contiguous
section of the block.
Row Format and Size
Limits on the number of columns in a table --- 256.
Each row piece, chained or unchained, contains ---
(i) row header
(ii) data for all or some of the columns of rows
3.
The image show a row piece in a data block.
The row piece consists of the
(i) row header – consists of (1) row overhead,
(2) number of columns,
(3) cluster key ID (if clustered),
(4) ROWID of chained row piece (if any).
It precedes the data and contains information about: (i) row pieces
(ii) chaining (for chained row pieces only)
(iii) columns in the row piece
(iv) cluster keys (for clustered data only)
(ii) column data – this section contains the column length and column value
NOTE: Each row consumes 2 BYTES of the ROW DIRECTORY in the block header.
the new row can take the rowid of the deleted row.]
(b) the row is exported and imported using Oracle Utilities
(c) if the clustered key values of a row change, then the row keeps
the same rowid but also gets an additional pointer rowid for the new values.
Physical Rowids – provide the fastest possible access to a row in a given table.
- contain the physical address of a row (down to the specific block) and allow one to
retrieve the row in a single block access.
- as long as a row is not deleted , its rowid remains unchanged.
- in CLUSTERED tables , rows in different tables that are in the same data block can have
the same rowid.
- a deleted row’s rowid can be reused by a transaction which is other than the
transaction that deleted the row.
SELECT ROWID, LAST_NAME FROM EMPLOYEES WHERE DEPARTMENT_ID=20; --- can return:
ROWID LAST_NAME
AAAAaoAATAAABrXAAA BORTINS
AAAAaoAATAAABrXAAE RUGGLES
AAAAaoAATAAABrXAAG CHEN
AAAAaoAATAAABrXAAN BLUMBERG
BBBBBB -> the “data block” that contains the row (block AAABrX in the example).
Block numbers are relative to their datafile, not tablespace. Therefore, two rows with
identical block numbers could reside in two different datafiles of the same tablespace.
“DBMS_ROWID” can be used to obtain the object_id for a corresponding extended rowid or to convert a
rowid from extended format to restricted format (vice versa).
RESTRICTED ROWID -> use a binary representation of the physical address for each row selected.
When queried using SQL* Plus, the binary representation is converted to a VARCHAR2/hexadecimal
representation.
Example:
SELECT ROWID, last_name FROM employees
WHERE department_id = 30;
can return the following row information:
ROWID ENAME
00000DD5.0000.0001 KRISHNAN
00000DD5.0001.0001 ARBUCKLE
00000DD5.0002.0001 NGUYEN
Jonathan Lewis
2. Daily Digest 2:
There are two ID's for a datafile and those are FILE_ID and RELATIVE_FILE_ID.
File_id is unqiue within the database for a file.
Relative_file_id is unique within a tablespace.
However , exception to the rule was highlighted by Tanel Poder where he said:
With the advent of "Transportable Tablespace" the file_id being unique in the database --- no more
holds.
That is the reason for the introduction of the 10 byte EXTENDED ROWID.
Till Oracle 7 , there was this 6 byte RESTRICTED ROWID only.
RESTRICTED ROWID - contains the Block,File and the Row information only.
Whereas EXTENDED ROWID - contains the objectid in addition to the block,file and row information.
So, in an extended rowid , the rowid will hold the objectid of which it is a row.
So, in a database with transportable tablespace , there might be two entries with the same file_id,
however, the EXTENDED ROWID's containing the file_id will be different.
This is because , the object_id is never the same.
- The reason for keeping the file_id same in transportable table is to keep the reference of the ROWID's
in the index same.
- In case of a Global Index on a partitioned table, each rowid in the leaf block should contain in addition
to BRF(block-row-file) , the objectid as well.
This is because , the 6 bytes Restricted Rowid will contain the file_id,row_id and block_id in the leaf
block.
Now, since the each partition of a table might reside in different tablespace , the file_id might be same
(if the relative file_id) is used. - [ RELATIVE FILE_ID IS USED CONFIRMED from Tanel's blog