an extended rowid needs 10 bytes of storage on disk and is displayed by using 18 characters. it consists of the following components:
• data object number: is assigned to each data object, such as table or index when it is created, and it is unique within the database
• relative file number: is unique to each file within a tablespace
• block number: represents the position of the block, containing the row, within the file
• row number: identifies the position of the row directory slot in the block header
internally, the data object number needs 32 bits, the relative file number needs 10 bits, block number needs 22 bits, and the row number needs 16 bits, adding up to a total of 80 bits or 10 bytes.
an extended rowid is displayed using a base-64 encoding scheme, which uses six positions for the data object number, three positions for the relative file number, six positions for the block number, and three positions for the row number. the base-64 encoding scheme uses characters a-z, a-z, 0-9, and /. this is a total of 64 characters, as in the following example:
rowid format (continued)
sql> select department_id, rowid from hr.departments;
department_id rowid
————- ——————
10 aaabqmaafaaaaa6aaa
20 aaabqmaafaaaaa6aab
30 aaabqmaafaaaaa6aac
40 aaabqmaafaaaaa6aad
50 aaabqmaafaaaaa6aae
60 aaabqmaafaaaaa6aaf
…
in this example:
• aaabqm is the data object number
• aaf is the relative file number
• aaaaa6 is the block number
• aaa is the row number for the department with id = 10
restricted rowid in oracle7 and earlier:
versions of the oracle database prior to oracle8 used the restricted rowid format. a restricted rowid used only six bytes internally and did not contain the data object number. this format was acceptable in oracle7 or an earlier release because the file numbers were unique within a database. thus, earlier releases did not permit more than 1,022 datafiles. now it is the limit for a tablespace.
even though oracle8 removed this restriction by using tablespace-relative file numbers, the restricted rowid is still used in objects like nonpartitioned indexes on nonpartitioned tables where all the index entries refer to rows within the same segment.
locating a row using rowid:
because a segment can only reside in one tablespace, by using the data object number, the oracle server can determine the tablespace that contains a row.
the relative file number within the tablespace is used to locate the file, the block number is used to locate the block containing the row, and the row number is used to locate the row directory entry for the row.
the row directory entry can be used to locate the beginning of the row.
thus, rowid can be used to locate any row within a database.
structure of a row
row data is stored in database blocks as variable-length records. columns for a row are generally stored in the order in which they are defined and any trailing null columns are not stored.
note: a single byte for column length is required for non trailing null columns. each row in a table has:
• row header: used to store the number of columns in the row, the chaining information, and the row lock status
• row data: for each column, the oracle server stores the column length and value (one byte is needed to store the column length if the column will require more than 250 bytes of storage in which case three bytes will be used for column length. the column value is stored immediately following the column length bytes.)
adjacent rows do not need any space between them. each row in the block has a slot in the row directory. the directory slot points to the beginning of the row.
from :
阅读(2086) | 评论(0) | 转发(0) |