SQLServerBIT字段存储(二)

2014-11-24 16:57:27 · 作者: · 浏览: 1
P Record Size = 18

Memory Dump @0x0000000013D6A060

0000000000000000: 10000f00 41414141 41034242 42424204 0000 ....AAAAA.BBBBB...

Slot 0 Column 1 Offset 0x4 Length 5 Length (physical) 5

a = AAAAA

Slot 0 Column 2 Offset 0x9 Length 1 (Bit position 0)

b = 1

Slot 0 Column 3 Offset 0xa Length 5 Length (physical) 5

c = BBBBB

Slot 0 Column 4 Offset 0x9 Length 1 (Bit position 1)

d = 1

Slot 1 Offset 0x72 Length 18

Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP Record Size = 18

Memory Dump @0x0000000013D6A072

0000000000000000: 10000f00 42424242 42004343 43434304 0000 ....BBBBB.CCCCC...

Slot 1 Column 1 Offset 0x4 Length 5 Length (physical) 5

a = BBBBB

Slot 1 Column 2 Offset 0x9 Length 1 (Bit position 0)

b = 0

Slot 1 Column 3 Offset 0xa Length 5 Length (physical) 5

c = CCCCC

Slot 1 Column 4 Offset 0x9 Length 1 (Bit position 1)

d = 0

Slot 2 Offset 0x84 Length 18

Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP Record Size = 18

Memory Dump @0x0000000013D6A084

0000000000000000: 10000f00 43434343 43024444 44444404 0000 ....CCCCC.DDDDD...

Slot 2 Column 1 Offset 0x4 Length 5 Length (physical) 5

a = CCCCC

Slot 2 Column 2 Offset 0x9 Length 1 (Bit position 0)

b = 0

Slot 2 Column 3 Offset 0xa Length 5 Length (physical) 5

c = DDDDD

Slot 2 Column 4 Offset 0x9 Length 1 (Bit position 1)

d = 1

Slot 3 Offset 0x96 Length 18

Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP Record Size = 18

Memory Dump @0x0000000013D6A096

0000000000000000: 10000f00 44444444 44014646 46464604 0000 ....DDDDD.FFFFF...

Slot 3 Column 1 Offset 0x4 Length 5 Length (physical) 5

a = DDDDD

Slot 3 Column 2 Offset 0x9 Length 1 (Bit position 0)

b = 1

Slot 3 Column 3 Offset 0xa Length 5 Length (physical) 5

c = FFFFF

Slot 3 Column 4 Offset 0x9 Length 1 (Bit position 1)

d = 0

DBCC 执行完毕。如果 DBCC 输出了错误信息,请与系统管理员联系。

更直观的比较

1、10000f00 41414141 41034242 42424204 0000

2、10000f00 42424242 42004343 43434304 0000

3、10000f00 44444444 44014646 46464604 0000

4、10000f00 44444444 44014646 46464604 0000

二进制的中间分别为 03 00 02 01

insert A1(a,b,c,d) values('AAAAA',1,'BBBBB',1) 03

insert A1(a,b,c,d) values('BBBBB',0,'CCCCC',0) 00

insert A1(a,b,c,d) values('CCCCC',0,'DDDDD',1) 02

insert A1(a,b,c,d) values('DDDDD',1,'FFFFF',0) 01

足以证明SQLServer 不管创建的顺序,都是试图压缩到一个BYTE上去,当然超过8位,会再一次申请一个新BYTE。