Oracle Database中关于null值的存储(二)
COUNT
---------- -------------------- ----------
1 dd
可以看到id=1 的row#=0 ,这里的最后一列COUNT(number类型)值为null ,没有存储在block中,并且count number 标识为 拥有2列 www.2cto.com
我们再来看第二行 id=2 row#=1 的row piece
BBED> p *kdbr[1]
rowdata[9]
----------
ub1 rowdata[9] @8169 0x2c
BBED> dump /v offset 8169 count 128
File: /u01/apps/oracle/oradata/fake/users01.dbf (4)
Block: 31 Offsets: 8169 to 8191 Dba:0x0100001f
-------------------------------------------------------
2c010302 c103ff02 c1032c01 0202c102 l ,... ... .,... .
02646401 06699f l .dd..i.
<16 bytes per line>
2c010302 c103ff02 c103 这些为第二行的rowpiece
对应表中的值为
ID NAME COUNT
---------- -------------------- ----------
2 2
www.2cto.com
第二列name(varchar2类型) 为null
这里是怎样存储的呢?因为不是row piece 中的最后一列,可以看到是使用了ff来表示长度为0
再来看第三行 id=null row#=2 的row piece
BBED> p *kdbr[2]
rowdata[0]
----------
ub1 rowdata[0] @8160 0x2c
BBED> dump /v offset 8160 count 128
File: /u01/apps/oracle/oradata/fake/users01.dbf (4)
Block: 31 Offsets: 8160 to 8191 Dba:0x0100001f
-------------------------------------------------------
2c0103ff 013202c1 042c0103 02c103ff l ,....2. .,... ..
02c1032c 010202c1 02026464 0106699f l . .,... ..dd..i.
<16 bytes per line>
www.2cto.com
rowpiece为 2c0103ff 013202c1 04
对应表中的值
dex@FAKE> select * from ts where id is null ;
ID NAME COUNT
---------- -------------------- ----------
2 3
可以看到第一列id(number类型) 为null
也是使用ff来表示的。
最后看一下第四行 id=4 row#=3 的row piece
BBED> dump /v offset 8154 count 128
File: /u01/apps/oracle/oradata/fake/users01.dbf (4)
Block: 31 Offsets: 8154 to 8191 Dba:0x0100001f
-------------------------------------------------------
2c020102 c1052c01 03ff0132 02c1042c l ,... .,....2. .,
010302c1 03ff02c1 032c0102 02c10202 l ... ... .,... ..
64640206 b2a1 l dd..
www.2cto.com
<16 bytes per line>
rowpiece 为2c020102 c105
对应表中的值为
dex@FAKE> select * from ts where id=4 ;
ID NAME COUNT
---------- -------------------- ----------
4
可以看到row piece 中表示row piece 中只包含1列
因为后两列 name 与 count 的值都为空,所以也没有使用ff来表示。
www.2cto.com
想想也是蛮有道理的,如果不使用ff来表示,没有办法保证列的顺序。
而当后面的列的值都为null的时候,自然可以省下1个字节的ff。
至此验证结束
验证结束