Oracle rowid
站前網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)公司!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、APP開(kāi)發(fā)、自適應(yīng)網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開(kāi)發(fā),運(yùn)營(yíng)維護(hù)。成都創(chuàng)新互聯(lián)公司成立于2013年到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來(lái)保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)公司。一: 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(一個(gè)表空間的數(shù)據(jù)文件數(shù))=(2^10)-1=1023
Max( 一個(gè)數(shù)據(jù)文件包含塊數(shù) )=2^22=4194304=4M(block)
Max( 一個(gè) block 包含行數(shù) )=2^16=65536=64k(rows)
Max(一個(gè)數(shù)據(jù)庫(kù)內(nèi)object
個(gè)數(shù)
)=2^32=4294967296=4G(objects)
Bigfile Datafile
Max(一個(gè)表空間的數(shù)據(jù)文件數(shù))=1
Max( 一個(gè)數(shù)據(jù)文件包含塊數(shù) )=2^(22+10)=4294967296=4G(block)
Max( 一個(gè) block 包含行數(shù) )=2^16=65536=64k(rows)
Max(一個(gè)數(shù)據(jù)庫(kù)內(nèi)object 個(gè)數(shù) )=2^32=4294967296=4G(objects)
測(cè)試如下:
(1) 創(chuàng)建測(cè)試數(shù)據(jù)
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;
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
---通過(guò)rowid計(jì)算對(duì)應(yīng)的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
---
也可以通過(guò)dbms_rowid轉(zhuǎn)換得到相應(yīng)的
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;
(3)rowid 和限制
Small Datafile
rowid 采用 10 個(gè) byte 來(lái)存儲(chǔ) =8*10=80bit ,
其中 :
obj# 占用 32bit ;
rfile# 占用 10bit ;
block# 占用 22bit ;
row# 占用 16bit 。
Max(一個(gè)表空間的數(shù)據(jù)文件數(shù))=(2^10)-1=1023
Max( 一個(gè)數(shù)據(jù)文件包含塊數(shù) )=2^22=41943044=4M(block)
Max( 一個(gè) block 包含行數(shù) )=2^16=65536=64k(rows)
Max(一個(gè)數(shù)據(jù)庫(kù)內(nèi)object 個(gè)數(shù) )=2^32=4294967296=4G(objects)
Bigfile Datafile
rowid 采用 10 個(gè) byte 來(lái)存儲(chǔ) =8*10=80bit ,
其中 :
obj# 占用 32bit ;
rfile# 占用 0bit ;
block# 占用 32bit ;
row# 占用 16bit 。
Max(一個(gè)表空間的數(shù)據(jù)文件數(shù))=2^0=1
Max( 一個(gè) block 包含行數(shù) )=2^16=65536=64k(rows)
Max(一個(gè)數(shù)據(jù)庫(kù)內(nèi)object 個(gè)數(shù) )=2^32=4294967296=4G(objects)
歡迎關(guān)注我的微信公眾號(hào)"IT小Chen",共同學(xué)習(xí),共同成長(zhǎng)?。?!