溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle rowid

發布時間:2020-08-04 18:12:53 來源:ITPUB博客 閱讀:246 作者:chenoracle 欄目:關系型數據庫

Oracle rowid


一: rowid 組成

https://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements001.htm#SQLRF00213

https://docs.oracle.com/cd/E11882_01/server.112/e41084/pseudocolumns008.htm#SQLRF00254

(1)The data object number of the object

(2)The data block in the data file in which the row resides

(3)The position of the row in the data block (first row is 0)

(4)The data file in which the row resides (first file is 1). The file number is relative to the tablespace.


二: rowid 重要用途

https://docs.oracle.com/cd/E11882_01/server.112/e41084/pseudocolumns008.htm#SQLRF00254

Rowid values have several important uses:

(1)They are the fastest way to access a single row.

(2)They can show you how the rows in a table are stored.

(3)They are unique identifiers for rows in a table.


三: rowid 限制

Small Datafile

Max(一個表空間的數據文件數)=(2^10)-1=1023

Max( 一個數據文件包含塊數 )=2^22=4194304=4M(block)

Max( 一個 block 包含行數 )=2^16=65536=64k(rows)

Max(一個數據庫內object 個數 )=2^32=4294967296=4G(objects)

Bigfile Datafile

Max(一個表空間的數據文件數)=1

Max( 一個數據文件包含塊數 )=2^(22+10)=4294967296=4G(block)

Max( 一個 block 包含行數 )=2^16=65536=64k(rows)

Max(一個數據庫內object 個數 )=2^32=4294967296=4G(objects)


測試如下:

(1)  創建測試數據

SQL> create tablespace chenjch_tbs datafile '/u01/app/oracle/oradata/cc/chenjch_tbs01.dbf' size 10M autoextend on maxsize 1G;

SQL> create user chenjch identified by a default tablespace chenjch_tbs;

SQL> grant connect,resource,dba to chenjch;

SQL> create table t1 as select * from scott.emp;

SQL> create table t2 as select * from scott.dept;

 

(2) 查看 t1 rowid 信息

SQL> SELECT rowid,empno from t1 a order by empno;

Oracle rowid

SQL>

select substr(rowid, 1, 6) "object",

       substr(rowid, 7, 3) "file",

       substr(rowid, 10, 6) "block",

       substr(rowid, 16, 3) "row"

  from t1;
---取出任意一行rowid

AAAVV9 AAF AAAACD AAC
---通過rowid計算對應的obj#,rfile#,block#,row#;

(1)obj#=AAAVV9=21*64^2+21*64+61= 87421

(2)rfile#=AAF= 5

(3)block#=AAAACD=2*64+3= 131

(4)row#=AAC= 2

Oracle rowid  


--- 也可以通過dbms_rowid轉換得到相應的
obj#,rfile#,block#,row#;
SQL>

se lect dbms_rowid.rowid_object(rowid) object_id,

       dbms_rowid.rowid_relative_fno(rowid) file_id,

       dbms_rowid.rowid_block_number(rowid) block_id,

       dbms_rowid.rowid_row_number(rowid) row_number,

       ROWID,

       empno

  from T1

 order by empno;

Oracle rowid  


(3)rowid 和限制

Small Datafile

rowid 采用 10 byte 來存儲 =8*10=80bit ,

其中 :

obj# 占用 32bit ;

rfile# 占用 10bit ;

block# 占用 22bit ;

row# 占用 16bit 。

Max(一個表空間的數據文件數)=(2^10)-1=1023

Max( 一個數據文件包含塊數 )=2^22=41943044=4M(block)

Max( 一個 block 包含行數 )=2^16=65536=64k(rows)

Max(一個數據庫內object 個數 )=2^32=4294967296=4G(objects)


Bigfile Datafile

rowid 采用 10 byte 來存儲 =8*10=80bit ,

其中 :

obj# 占用 32bit ;

rfile# 占用 0bit ;

block# 占用 32bit ;

row# 占用 16bit 。

Max(一個表空間的數據文件數)=2^0=1

Max( 一個 block 包含行數 )=2^16=65536=64k(rows)

Max(一個數據庫內object 個數 )=2^32=4294967296=4G(objects)

歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長?。?!

Oracle rowid

Oracle rowid


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女