简体   繁体   English

NVarchar(MAX)用于短字符串

[英]NVarchar(MAX) for short strings

I am interested is NVarchar(MAX) a good data type is I want to store short unicode strings which are 1-50 characters long, but most of them (more than 90%) are 5-10 characters long? 我感兴趣的是NVarchar(MAX)是一种很好的数据类型,我想存储长度为1至50个字符的短Unicode字符串,但是其中大多数(超过90%)的字符串为5至10个字符吗?

The column will not be used in comparison and ordering queries. 该列将不用于比较和排序查询。 It might be added to index as included column. 它可能会作为包含的列添加到索引中。 Expected rows count - more than 10M. 预期的行数-超过1000万。

Any recommendations? 有什么建议吗? Thank you in advance! 先感谢您!

Why would you use nvarchar(MAX) for such short strings? 为什么对这样的短字符串使用nvarchar(MAX)? If you know the maximum length is 50 characters, make it nvarchar(50). 如果知道最大长度为50个字符,则将其设置为nvarchar(50)。

Also, I do not believe an nvarchar(MAX) column can be included in an index as it would break the 900 byte limit. 另外,我不认为nvarchar(MAX)列可以包含在索引中,因为它会破坏900字节的限制。

我建议如果最大长度确实是50,则nvarchar(50)更合适。

NVARCHAR(MAX) (which I believe is the same as NTEXT in the earlier versions of SQL server) is intended for storing long text values of variable and potentially unlimited length. NVARCHAR(MAX)(我相信与SQL Server的早期版本中的NTEXT相同)旨在存储可变且可能无限长的长文本值。

If you know the values won't exceed N characters, you should use NVARCHAR(N). 如果您知道值不会超过N个字符,则应使用NVARCHAR(N)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM