解密SQL 服务器页面存储

Decipher SQL Server page storage

CREATE TABLE tbl
  (
     col1 VARCHAR(1)
  )

INSERT INTO tbl
VALUES     (NULL)

DBCC traceon(3604)

DBCC ind(0, tbl, -1)

DBCC page(0, 1, 290, 3) WITH tableresults /*Change page number as required*/

输出

PAGE HEADER:    Slot 0 Offset 0x60 Length 9 Record Type PRIMARY_RECORD
PAGE HEADER:    Slot 0 Offset 0x60 Length 9 Record Attributes    NULL_BITMAP
PAGE HEADER:    Slot 0 Offset 0x60 Length 9 Record Size 9
Slot 0 Offset 0x60 Length 9 Memory Dump @0x000000001646A060     
10000400 01000100 d8                          ........Ø

这里的d8是什么?

这只是填充,

该行只需要占用上面突出显示的 7 个字节(行末尾的 null 或空 varchar 列 needs no space) but the minimum row size is 9 bytes 因此您看到的是上一页之前页面上的任何内容的垃圾两个字节。