一个块存储一条记录的巧妙设计

--因为块大小等于8K,每个块存储一个行

--因为块大小等于8K,所以创建7.K的行,则一个行占据一个块。

--PCTFREE=10,因此一个行在8K*0.9=7.2K以上,就可以占据一个块。

总共长度为7500bytes

SQL> create table hwm_test(
  2  name1 char(2000) default '',
  3  name2 char(2000) default '',
  4  name3 char(2000) default '',
  5  name4 char(1500) default '');

Table created.

SQL> select replace(name1,' ',''),replace(name2,' ',''),replace(name3,' ',''),replace(name4,' ','') from hwm_test;

REPLACE(NA REPLACE(NA REPLACE(NA REPLACE(NA
---------- ---------- ---------- ----------
1	   1	      1 	 1
2	   2	      2 	 2

SQL> select count(distinct dbms_rowid.rowid_block_number(rowid))from hwm_test;

COUNT(DISTINCTDBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID))
---------------------------------------------------
						  2

SQL> insert into hwm_test values(3,3,3,3);

1 row created.

SQL> commit;

Commit complete.

SQL> select count(distinct dbms_rowid.rowid_block_number(rowid))from hwm_test;

COUNT(DISTINCTDBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID))
---------------------------------------------------
						  3

SQL> insert into hwm_test values(4,4,4,4);

1 row created.

SQL> commit;

Commit complete.

SQL> select count(distinct dbms_rowid.rowid_block_number(rowid))from hwm_test;

COUNT(DISTINCTDBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID))
---------------------------------------------------
						  4



SQL> select rowid,dbms_rowid.rowid_block_number(rowid) from hwm_test;

ROWID		   DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
------------------ ------------------------------------
AAAoxhAALAAACsKAAA				  11018
AAAoxhAALAAACsLAAA				  11019
AAAoxhAALAAACsMAAA				  11020
AAAoxhAALAAACsNAAA				  11021

通过dbms_rowid.rowid_block_number(rowid)找到记录对应的block号

你可能感兴趣的:(一个块存储一条记录的巧妙设计)