1024programmer Oracle Understanding oracleROWID

Understanding oracleROWID

Understanding oracle ROWID
the
The data is stored in the data file, and its attributes will be determined along with the storage. These attributes include: which data file? Which object does it belong to? Where is the data block located? line number? Combining these attributes constitutes the oracle ROWID.
the
Therefore, the rowid records the location of the data on the disk in detail.
www.2cto.com
ROWID can be divided into: physical and logical. Except IOT uses logical ROWID, other types of tables use physical ROWID.
ROWID can also be divided into: restricted and extended. After 8i use extended rowid.
The following introduces the extended rowid.
Extended rowid, using 64-bit encoding, press 6, 3 to open.
example:
[sql]
SQL> show user
USER is “HR”
SQL> drop table t1 purge;
drop table t1 purge
* *
Error on line 1:
ORA-00942: table or view does not exist
the
SQL> create table t1 (id number,name varchar2(20));
the
The table has been created. the
www.2cto.com
SQL> insert into t1 values(1,'a');
the
It has created a row. the
the
SQL> insert into t1 values(2,'b'); 
the
It has created a row. the
the
SQL> commit;
the
Commit complete. the
the
SQL> select rowid,t1.* from t1;
the
ROWID ID NAME
—————— ———- ———————- —————— 
AAANFgAAEAAAAHYAAA 1 a
AAANFgAAEAAAAHYAAB 2 b
                                                                                      64 encoding tables
base64 means number sequence
A~Z 0~25
a~z 26~51
0~9 52~61
+ 62
/ 63
id=1 and its corresponding rowid is: AAANFg AAE AAAAHY AAA
AAANFg: www.2cto.com
Segment number (corresponding to data_object_id of dba_data_files). Please note that it is different from object_id. object_id is the object number, uniquely identifies the object, and is the ID card of the object (different from the segment number: the segment must be an object, but the object is not necessarily a segment). If the physical location changes, such as moving the table space, the data_object_id will also change. If the object name is changed, the object_id will not be affected. Truncate will also change the segment number, because truncate is a DDL statement that deletes the metadata of the table from the data dictionary and returns the HWM at the same time, but the data is not deleted.
From the above table: A=0 N=13 F=5 g=32
the
[sql]
SQL> select 13*power(64,2)+5*64+32 from dual;
the
13*POWER(64,2)+5*64+32
———————- 
                                                   
We can also use the dbms_rowid package to find:
[sql]
SQL> select dbms_rowid.rowid_object('AAANFgAAEAAAAHYAAA') from dual;
the
DBMS_ROWID.ROWID_OBJECT('AAANFGAAEAAAAAHYAAA') 
———————————————— 
                                                                     
www.2cto.com
AAE
Relative file number (relative_fno), at the tablespace level. Note the difference with the absolute file number (file_id), at the database level.


the
AAAAHY
The data block number
AAA
line number
The status of ROWID in oracle is self-evident. The essence of the index is to use ROWID, because the index saves the rowid, and then locates the record in the data table according to the rowid. Imagine a book, the index is the table of contents, and the content of the book is the data, then the rowid is the “page number” that links the table of contents and the content.
the
the
Author linwaterbin

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/understanding-oraclerowid/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索