解析数据页面头部结构:
if object_id('test') is not null
drop table test
go
create table test( id int,birth datetime,name char(10))
insert into test
select 1,'2009-11-27','aaaa' union all
select 2,'2009-11-27','aaaa'
exec sp_spaceused 'test'
结构:
name
rows
reserved
Data
index_size
unused
test
2
16 KB
8 KB
8 KB
0 KB
通过dbcc ind (test,test,0) 可以查看到该表有两个页,页号分别为109,和89,其中89为数据页。下面通过dbcc page 我们可以查看到该数据页的头部结构,下面我们就来解析头部结构每一个字段的含义。
dbcc traceon(3604)
dbcc page(test,1,89,1)
m_pageId = (1:89)
数据页号
m_headerVersion = 1
头文件版本号,从7.0以后,一直为1
m_type = 1
页面类型,1为数据页
m_typeFlagBits = 0x4
数据页和索引页为4,其他页为0
m_level = 0
该页在索引页(B树)中的级数
m_flagBits = 0x8000
页面标志
m_objId (AllocUnitId.idObj) = 83
m_indexId (AllocUnitId.idInd) = 256
Metadata: AllocUnitId = 72057594043367424
存储单元的ID
Metadata: PartitionId = 72057594038386688
数据页所在的分区号
Metadata: IndexId = 0
页面的索引号
Metadata: ObjectId = 2089058478
该页面所属的对象的id,可以使用object_id获得
m_prevPage = (0:0)
该数据页的前一页面
m_nextPage = (0:0)
该数据页的后一页面
pminlen = 26
定长数据所占的字节数
m_slotCnt = 2
页面中的数据的行数
m_freeCnt = 8034