如何达到每行 8060 字节和每个(varchar、nvarchar)值 8000 个字节的限制?
来自我的问题“8060 B 数据页中的 8078 字节(SQL Server )?”,其中向我解释了如何在 MS SQL Server 中导出每页 8078 字节的数据。
如果我计算每页用于仅一行和一列非索引固定大小类型记录的数据存储(无开销)的字节数(根据 MSDN 文章 估计堆的大小),然后我得到 8087 字节(每页)。
如何在不购买和学习 1000 多页书籍的情况下达到每行 8060 字节(在我的其他问题的答案中提到)和每行 8000 字节(varchar、nvarchar)的限制?
我肯定在存储分配中遗漏了一些东西:要管理的块越少,开销就越大......
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.
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).
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
存储引擎内部:剖析一条记录
这是用于SQL Server 2005
版本控制标签
因此,对于一个 char(8000)
但是,如果有 40 varchar(200) 列
总计 = 8080 + 4 + 6 + 2 + 14 = 8106。WTF?创建此表时您会收到警告
我不会太在意它:此信息没有日常实用价值
Inside the Storage Engine: Anatomy of a record
This is for SQL Server 2005
versioning tag
So, for one char(8000)
However, if you had 40 varchar(200) columns
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 字节而不是其他数字?”,或者“为什么 NVARCHAR 的最大长度是 8000 字节?”那么简短的答案是,谁知道呢? (正如 gbn 所说,谁在乎呢?)
所有 MSSQL 限制 - 数据类型大小、最大行大小、每个表的列数、每个索引的列数等 - 只是 Microsoft 的设计决策。我非常确定决策背后有大量的工程文档,但大多数人无法访问这些信息。
如果您对限制是什么、行大小如何计算等具体细节感兴趣,那么阅读 MSSQL 文档是最好的起点。
I'm not totally sure what you're asking, but if your question is "why is the maximum row length 8060 bytes and not some other number?", or "why does NVARCHAR have a maximum length of 8000 bytes?" then the short answer is, who knows? (And as gbn said, who cares?)
All MSSQL limits - data type sizes, maximum row size, columns per table, columns per index etc. - are just design decisions by Microsoft. I'm quite sure that there is a huge amount of engineering documentation behind the decisions, but most people don't have access to that information.
If you're interested in specific details of what the limits are, how row size is calculated etc. then reading the MSSQL documentation is the best place to start.