在表中使用 VARCHAR(MAX) 有什么缺点吗? [英] Are there disadvantages to using VARCHAR(MAX) in a table?

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

问题描述

这是我的困境.

基本上,我需要表格中的一列来容纳未知长度的字符.但是我很好奇在列中使用 VARCHAR(MAX) 或 NVARCHAR(MAX) 在 Sql Server 中是否会出现性能问题,例如:这次"我只需要存储 3 个字符,大多数时候我只需要存储 10 个字符.但是有一个很小的可能性,该列中最多可能有几千个字符,甚至可能有一百万个字符,这是不可预测的.但是,我可以保证它不会超过 2GB 的限制.

Basically, I need a column in a table to hold up an unknown length of characters. But I was curious if in Sql Server performance problems could arise using a VARCHAR(MAX) or NVARCHAR(MAX) in a column, such as: 'This time' I only need to store 3 characters and most of the time I only need to store 10 characters. But there is a small chances that It could be up to a couple thousand characters in that column, or even possibly a million, It is unpredictable. But, I can guarantee that it will not go over the 2GB limit.

我只是想知道是否存在任何性能问题,或者在可能的情况下解决此问题的更好方法.

I was just curious if there are any performance issues, or possibly better ways of solving this problem where available.

推荐答案

在我看来,您打算将 varchar(MAX) 数据类型用于其预期目的.

Sounds to me like you plan to use the varchar(MAX) data type for its intended purpose.

当 MAX 数据类型中的数据超过 8 KB 时,使用溢出页面.SQL Server 2005 会自动为页面分配一个溢出指示符,并且知道如何像处理其他数据类型一样处理数据行.

When data in a MAX data type exceeds 8 KB, an over-flow page is used. SQL Server 2005 automatically assigns an over-flow indicator to the page and knows how to manipulate data rows the same way it manipulates other data types.

要进一步阅读,请查看联机丛书:char 和varchar

For further reading, check out Books Online: char and varchar

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

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