总是使用 nvarchar(MAX) 有什么缺点吗? [英] Are there any disadvantages to always using nvarchar(MAX)?

查看:34
本文介绍了总是使用 nvarchar(MAX) 有什么缺点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SQL Server 2005 中,将所有字符字段设为 nvarchar(MAX) 而不是显式指定长度是否有任何缺点,例如nvarchar(255)?(除了你不能在数据库级别限制字段长度这一显而易见的)

In SQL Server 2005, are there any disadvantages to making all character fields nvarchar(MAX) rather than specifying a length explicitly, e.g. nvarchar(255)? (Apart from the obvious one that you aren't able to limit the field length at the database level)

推荐答案

在 MSDN 论坛上提出了同样的问题:

Same question was asked on MSDN Forums:

来自原始帖子(那里有更多信息):

From the original post (much more information there):

当您将数据存储到 VARCHAR(N) 列时,值的物理存储方式相同.但是,当您将其存储到 VARCHAR(MAX) 列时,屏幕后面的数据将作为 TEXT 值处理.因此在处理 VARCHAR(MAX) 值时需要一些额外的处理.(仅当大小超过 8000 时)

When you store data to a VARCHAR(N) column, the values are physically stored in the same way. But when you store it to a VARCHAR(MAX) column, behind the screen the data is handled as a TEXT value. So there is some additional processing needed when dealing with a VARCHAR(MAX) value. (only if the size exceeds 8000)

VARCHAR(MAX) 或 NVARCHAR(MAX) 被视为大值类型".大值类型通常存储在行外".这意味着数据行将有一个指向存储大值"的另一个位置的指针...

VARCHAR(MAX) or NVARCHAR(MAX) is considered as a 'large value type'. Large value types are usually stored 'out of row'. It means that the data row will have a pointer to another location where the 'large value' is stored...

这篇关于总是使用 nvarchar(MAX) 有什么缺点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆