MSDN has this to say关于主题:
nvarchar [ ( n | max ) ]
Variable-length Unicode character data. ncan be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes. The storage size, in bytes, is two times the number of characters entered + 2 bytes. The data entered can be 0 characters in length. The ISO synonyms for nvarchar are national char varying and national character varying.
这让我很困惑。我可以将一列定义为 1 - 4000 长,或 2147483647 长但两者之间什么都没有?我的理解正确吗?为什么我不能明确说明两者之间的值?
最佳答案
NVARCHAR(MAX)
涵盖所有其他内容(不仅仅是 20 亿个字符)。如果您需要超过 4,000 个字符,数据肯定会超出页面,因此就行为而言,您使用了 4,001 个字符、10,000 个字符还是 10,000,000 个字符都没有关系。它只占用您需要的空间,所以不要认为您在浪费 (20 亿个字符 - 实际字符串的长度)
。
关于sql - nvarchar(4001)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6929969/