如何达到每行8060字节和8000(varchar,nvarchar)值的限制? [英] How do you get to limits of 8060 bytes per row and 8000 per (varchar, nvarchar) value?
问题描述
来自我的问题 8060 B数据表中的8078字节(SQL Server)?在哪里向我解释如何在MS SQL Server中每页导出8078字节的数据。
Comining from my question "8078 bytes in 8060 B datapage (SQL Server)?" where it was explained to me how to derive 8078 bytes of data per page in MS SQL Server.
如果我计算用于数据存储(无开销)的每页的字节数,只有一行与一列非索引固定大小类型的记录(as根据MSDN文章估计堆的大小),然后我来到8087字节(每页)。
If I calculate the number of bytes per page used for data storage (without overhead) of only one row with one column of non-indexed fixed-size type record (as per the MSDN article Estimating the Size of a Heap), then I come to 8087 bytes (per page).
如何达到每行8060字节(在我的其他问题的答案中提到)的限制,并且每个( varchar,nvarchar)没有购买和研究1000多页的书籍?
How do I get to to the limits of 8060 bytes per row (mentioned in my other question's answers) and to 8000 bytes per (varchar, nvarchar) without buying and studying 1000+ page books?
我确实在存储分配中缺少一些东西:管理的块越少,开销越多...
I am certainly missing something in storage allocation: the fewer chunks to manage, the more overhead...
推荐答案
这是针对SQL Server 2005
This is for SQL Server 2005
- 记录标题
- 4 b ytes long
- 两个字节的记录元数据(记录类型)
- 两个字节在记录中指向NULL位图
- 记录中列数计数的两个字节
- 可变数量的字节,用于存储记录中每列的一位,无论列是否为空(这与SQL Server 2000不同,简单,每个可空列只有一位) li>
- 这可以在读取NULL列时进行优化
- 可变长度列的计数的两个字节
- 每个变量长度列的两个字节,给出列值结尾的偏移量
版本控制标签
所以,对于一个char(8000)
So, for one char(8000)
- 4个字节(记录头)</ li>
- 8000固定长度
- 3 null位图
- 2个字节计算可变长度
- 14时间戳
- 4 bytes (record header)
- 8000 fixed length
- 3 null bitmap
- 2 bytes to count variable-length
- 14 timestamp
但是,如果您有40个varchar(200)列
However, if you had 40 varchar(200) columns
- 4个字节(记录头)
- 0固定长度
- 6 null位图
- 2个字节计数可变长度
- 202 x 40 = 8080
- 14时间戳
- 4 bytes (record header)
- 0 fixed length
- 6 null bitmap
- 2 bytes to count variable-length
- 202 x 40 = 8080
- 14 timestamp
总计= 8080 + 4 + 6 + 2 + 14 = 8106.WFF创建此表时,您会收到警告
Total = 8080 + 4 + 6 + 2 + 14 = 8106. WTF? You get a warning when you created this table
我不会太挂断它:此信息具有无实用的日常价值
I would not get too hung up on it: this information has no practical day to day value
这篇关于如何达到每行8060字节和8000(varchar,nvarchar)值的限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!