使用VARCHAR(max),NVARCHAR(max)和VARBINARY(max)而不是TEXT,NTEXT和IMAGE有什么好处?

时间:2022-03-30 16:54:37

I know TEXT, NTEXT and IMAGE are deprecated and will, eventually, be removed from SQL Server.

我知道TEXT,NTEXT和IMAGE已被弃用,最终将从SQL Server中删除。

But, besides this deprecation, why are VARCHAR(max), NVARCHAR(max) and VARBINARY(max) datatypes better? Why did Microsoft chose them?

但是,除了这种弃用之外,为什么VARCHAR(max),NVARCHAR(max)和VARBINARY(max)数据类型更好?为什么微软会选择它们?

I noticed VARCHAR and NVARCHAR can be used with = and GROUP BY, while the old types can't. Are there more benefits?

我注意到VARCHAR和NVARCHAR可以和=和GROUP BY一起使用,而旧类型则不能。有更多的好处吗?

2 个解决方案

#1


5  

The data types were deprecated because with the advancement of SQL Server, it is no longer necessary to treat large blocks of text (TEXT) or binary data (IMAGE) any different to VARCHAR or BINARY. With storage not really being a problem anymore, we can now do SUBSTRING(<varchar(max)>, 1234567, 400) to your heart's content whereas in the old days, 1 MB seemed like a lot and required special handling, such as the functions in this article.

不推荐使用数据类型,因为随着SQL Server的发展,不再需要将大块文本(TEXT)或二进制数据(IMAGE)与VARCHAR或BINARY区别对待。由于存储不再是一个问题,我们现在可以根据您的心脏内容进行SUBSTRING( ,1234567,400),而在过去,1 MB似乎很多,需要特殊处理,例如本文中的函数。 (max)>

IMAGE carries similar baggage to TEXT, which requires storing the size in a special way rather than expanding VARBINARY to cater for anything all the way to 2GB.

IMAGE带有类似于TEXT的行李,它要求以特殊方式存储大小,而不是扩展VARBINARY以满足任何方式的任何方式,直至2GB。

However, the same reasons for having specialized BLOBs and CLOBs is still valid under memory/storage constraints, so SQL Server CE continues to have the IMAGE type and it's not going away anytime soon on that front.

但是,具有专用BLOB和CLOB的相同原因在内存/存储限制下仍然有效,因此SQL Server CE继续具有IMAGE类型,并且它不会很快就会消失。

#2


1  

Because they are deprecated or not going to be supported

因为它们已被弃用或不受支持

Important ntext , text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.

将来的Microsoft SQL Server版本中将删除重要的ntext,text和image数据类型。避免在新的开发工作中使用这些数据类型,并计划修改当前使用它们的应用程序。请改用nvarchar(max),varchar(max)和varbinary(max)。

Related questions

相关问题

#1


5  

The data types were deprecated because with the advancement of SQL Server, it is no longer necessary to treat large blocks of text (TEXT) or binary data (IMAGE) any different to VARCHAR or BINARY. With storage not really being a problem anymore, we can now do SUBSTRING(<varchar(max)>, 1234567, 400) to your heart's content whereas in the old days, 1 MB seemed like a lot and required special handling, such as the functions in this article.

不推荐使用数据类型,因为随着SQL Server的发展,不再需要将大块文本(TEXT)或二进制数据(IMAGE)与VARCHAR或BINARY区别对待。由于存储不再是一个问题,我们现在可以根据您的心脏内容进行SUBSTRING( ,1234567,400),而在过去,1 MB似乎很多,需要特殊处理,例如本文中的函数。 (max)>

IMAGE carries similar baggage to TEXT, which requires storing the size in a special way rather than expanding VARBINARY to cater for anything all the way to 2GB.

IMAGE带有类似于TEXT的行李,它要求以特殊方式存储大小,而不是扩展VARBINARY以满足任何方式的任何方式,直至2GB。

However, the same reasons for having specialized BLOBs and CLOBs is still valid under memory/storage constraints, so SQL Server CE continues to have the IMAGE type and it's not going away anytime soon on that front.

但是,具有专用BLOB和CLOB的相同原因在内存/存储限制下仍然有效,因此SQL Server CE继续具有IMAGE类型,并且它不会很快就会消失。

#2


1  

Because they are deprecated or not going to be supported

因为它们已被弃用或不受支持

Important ntext , text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.

将来的Microsoft SQL Server版本中将删除重要的ntext,text和image数据类型。避免在新的开发工作中使用这些数据类型,并计划修改当前使用它们的应用程序。请改用nvarchar(max),varchar(max)和varbinary(max)。

Related questions

相关问题