ROWID structure of oracle8

Source: Internet
Author: User

1. Why is ROWID used?
ORACLE uses ROWID as the unique identifier of the B-tree and its internal algorithm to mark the ROW.
In versions earlier than ORACLE8, ROWID marks FILE, BLOCK, and row number, and uses only one numeric generation.
Table FILE number.
In ORACLE8, a DATAFILE has two numbers:
An absolute value is unique throughout the database. You can see the FILE_ID in DBA_DATA_FILES.
A relative value, which is unique in TABLESPACE, can be viewed in RELATIVE _
FNO.

The new ROWID uses relative values. Therefore, you must store the ID of the SEGMENT. Otherwise, it will be confused. So ORAC
LE8 adds the object's SEGMENT number to ROWID to indicate TABLE or PARTITION.

2. ROWID Structure
Use base-64 code, including a-z, A-Z, 0-9, + ,-. A total of 18 digits.
1-6 digits: representing the OBJECT
7-9 bits: relative file value
10-15: BLOCK in the file
16-18: SLOT value in the BLOCK

3. TABLESPACE-Relative addressing
TABLESPACE-Relative addressing is used. Multiple files can have the same Relative value because of its
They belong to different tablespaces, so we cannot get an absolute address from the new ROWID, but this is no problem.
When processing an OBJECT, you can determine which TABLESAPCE it belongs. In TABLES
In PACE, the OBJECT relative value is unique, so ROWID can uniquely identify an OBJECT. TABLE
SPACE-Relative addressing is a key technology in ORACLE8 that supports ultra-large databases.

4. DATA OBJECT NUMBER
Data object number indicates the SEGMENT. all segments have data object number,
It is stored in each data block and is not repeated.

At the beginning, DBA_OBJECTS.OBJECT_ID = DBA_OBJECTS.DATA-OBJECT_ID, but in
In the above case, the DATA-OBJECT_ID will increase in the following circumstances
TRUNCATE TABLE
MOVE PARTITION
ORACLE checks the data object number in ROWID and the data object number in the BLOCK,
Ensure that the versions are consistent.
ORACLE also uses data object number to ensure ROLLBACK record and latest SEGMENT record 1
To.
Note that the data object number is not an OBJECT identifier.


5. RESTRICTED ROWID
The ROWID format of ORACLE7 is
1-8 bits: BLOCK NUMBER
9-12 digits: ROW NUMBER
13-16 bits: FILE NUMBER
ORACLE8 supports short and old format rowids.
Index entry for NOPARTITION TABLE
Local index entry for PARTITION TABLE
ROW Piece CHain pointer
The internal storage of restricted ROWID is 6 bytes,
4 BYTE = DATA BLOCK NUMBER
2 BYTE = ROW NUMBER
This means that the index entry uses 6 bytes to store the ROWID, which is sufficient for most indexes. However
This short ROWID cannot be used on the global index of the patition table, because PARTITION may
Cross-TABLESPACE. It shows that this ROWID is still 18 bits.

6. Extended ROWID
ORACLE stores 10 bytes internally, including data object number and data block nu.
MBER, row number)
ORACLE8 uses the extended ROWID:
Partition table's GLOBAL INDEX
SERVER Algorithm
The extended ROWID is still 18 characters displayed in the SELECT statement, and is stored in the ROWID field.

7. Use the ROWID of ORACLE7 in ORACLE8
When you query the ROWID of ORACLE7 from an ORACLE8 database, ROWID returns the format of ORACLE7.
Used in the WHERE statement.
When you query the ROWID of ORACLE8 from the database of ORACLE7, ROWID returns the format of ORACLE8.
It is used in the WHERE statement, but cannot be stored in the ROWID field. However, you must use the DBMS_ROWID package.
Explanation.
If the extended ORACLE8 ROWID is included, the data of ORACLE8 cannot be imported to ORACLE7. Slave
You can IMPORT data from ORACLE7 to ORACLE8.

8. APPLICATION migration problems
Generally, there should be no problem with program porting. The porting problem is considered only in the following situations:
Application uses rowid
Table includes ROWID fields.
If the program has the following conditions, you must use the DBMS_ROWID package:
Self-Assembled ROWID
Self-decomposition of ROWID
If only ROWID is passed to the variable or used as a whole, it is not affected.


9. data migration problems
Regardless of whether EXPORT/IMPORT is used or the port migration tool, the ROWID field in ORACLE7 is included in ORACLE8.
It automatically expands.
If a field contains ROWID, you must manually use the DBMS_ROWID package for conversion.

10. DBMS_ROWID package
Created by $ ORACLE_HOME/rdbms/admin/dbmsutil. SQL, it is included in catproc. SQL
. Provides some functions for processing ROWID.
ROWID_CREATE
ROWID_INFO
ROWID_TYPE
ROWID_OBJECT
ROWID_RELATIVE_FNO
ROWID_BLOCK_NUMBER
ROWID_TO_ABSOLUTE_FNO
ROWID_TO_EXTENDED
ROWID_TO_RESTRICTED
ROWID_VERIFY

DBMS_ROWID.ROWID_TO_EXTENDED
(Old_rowid in ROWID,
Schema_name in varchar2,
Object_name in varchar2,
Conversion_type in number
)
Return rowid;
Convert restricted rowid to extended rowid, which is used to convert the old ROWID to ORACLE8 format.


DBMS_ROWID.ROWID_TO_RESTRICTED
Convert the extended ROWID to the restricted ROWID.

DBMS_ROWID.ROWID_VERIFY
Determines whether a restricted ROWID can be converted to an extended format.


DBMS_ROWID.ROW_INFO
Used to explain ROWID. You can obtain data object number, relative file number, and BLOCK.
NUMBER and row number.

DBMS_ROWID.CREATE
Generate ROWID.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.