SQL 服务器数据页中缺少字节
Missing bytes in SQL Server data page
不知道如何正确调用标题。但是,我试图了解数据页的存储方式。我创建了简单的 table:
CREATE TABLE testFix
(
id INT,
v CHAR(10)
);
INSERT INTO dbo.testFix
(
id,
v
)
VALUES
( 1, -- id - int
'asdasd' -- v - varchar(100)
)
GO 2
DBCC TRACEON(3604);
然后我通过以下命令获得了PageFID和PagePID:
DBCC IND(tempdb, testFix, -1)
GO
那么实际的数据页数:
DBCC PAGE (tempdb, 1, 368, 3)
所以现在我看到了:
Slot 0 Offset 0x60 Length 21
Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP
Record Size = 21
Memory Dump @0x000000287DD7A060
0000000000000000: 10001200 01000000 61736461 73642020 20200200
........asdasd .. 0000000000000014: 00
.
Slot 0 Column 1 Offset 0x4 Length 4 Length (physical) 4
id = 1
Slot 0 Column 2 Offset 0x8 Length 10 Length (physical) 10
v = asdasd
Slot 1 Offset 0x75 Length 21
Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP
Record Size = 21
Memory Dump @0x000000287DD7A075
0000000000000000: 10001200 01000000 61736461 73642020 20200200
........asdasd .. 0000000000000014: 00
.
Slot 1 Column 1 Offset 0x4 Length 4 Length (physical) 4
id = 1
Slot 1 Column 2 Offset 0x8 Length 10 Length (physical) 10
v = asdasd
Slot 2 Offset 0x8a Length 21
Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP
Record Size = 21
Memory Dump @0x000000287DD7A08A
0000000000000000: 10001200 01000000 61736461 73642020 20200200
........asdasd .. 0000000000000014: 00
所以记录的长度是21字节。但是 INT 是 4 个字节,而 CHAR(10) 是 10 个字节。 4+10=14。其他 7 个字节用于什么?
这里是数据行"anatomy"
红色部分缺少 7 个字节:状态位 A (1)、状态位 B (1)、Fdata 长度 (2)、Ncols (2)、NullBits (1)
不知道如何正确调用标题。但是,我试图了解数据页的存储方式。我创建了简单的 table:
CREATE TABLE testFix
(
id INT,
v CHAR(10)
);
INSERT INTO dbo.testFix
(
id,
v
)
VALUES
( 1, -- id - int
'asdasd' -- v - varchar(100)
)
GO 2
DBCC TRACEON(3604);
然后我通过以下命令获得了PageFID和PagePID:
DBCC IND(tempdb, testFix, -1)
GO
那么实际的数据页数:
DBCC PAGE (tempdb, 1, 368, 3)
所以现在我看到了:
Slot 0 Offset 0x60 Length 21
Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP
Record Size = 21Memory Dump @0x000000287DD7A060
0000000000000000: 10001200 01000000 61736461 73642020 20200200 ........asdasd .. 0000000000000014: 00
.Slot 0 Column 1 Offset 0x4 Length 4 Length (physical) 4
id = 1
Slot 0 Column 2 Offset 0x8 Length 10 Length (physical) 10
v = asdasd
Slot 1 Offset 0x75 Length 21
Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP
Record Size = 21Memory Dump @0x000000287DD7A075
0000000000000000: 10001200 01000000 61736461 73642020 20200200 ........asdasd .. 0000000000000014: 00
.Slot 1 Column 1 Offset 0x4 Length 4 Length (physical) 4
id = 1
Slot 1 Column 2 Offset 0x8 Length 10 Length (physical) 10
v = asdasd
Slot 2 Offset 0x8a Length 21
Record Type = PRIMARY_RECORD Record Attributes = NULL_BITMAP
Record Size = 21Memory Dump @0x000000287DD7A08A
0000000000000000: 10001200 01000000 61736461 73642020 20200200 ........asdasd .. 0000000000000014: 00
所以记录的长度是21字节。但是 INT 是 4 个字节,而 CHAR(10) 是 10 个字节。 4+10=14。其他 7 个字节用于什么?
这里是数据行"anatomy"
红色部分缺少 7 个字节:状态位 A (1)、状态位 B (1)、Fdata 长度 (2)、Ncols (2)、NullBits (1)