VARBINARY(MAX) 和 IMAGE 数据类型之间有很大的技术差异吗?

发布于 2024-09-30 17:50:05 字数 372 浏览 0 评论 0原文

我在互联网上阅读了这些关于 SQL Server 数据类型的声明:

  1. VARBINARY(MAX) - 二进制字符串 具有可变长度可以存储 到 2^31-1 字节。

  2. IMAGE - 带有 a 的二进制字符串 可变长度最大为 2^31-1 (2,147,483,647) 字节。

VARBINARY(MAX)IMAGE 数据类型之间是否存在很大的技术差异?

如果有区别:我们是否必须自定义 ADO.NET 在 SQL Server 中插入和更新图像数据字段的方式?

I was reading on internet these statements about SQL Server data types:

  1. VARBINARY(MAX) - Binary strings
    with a variable length can store up
    to 2^31-1 bytes.

  2. IMAGE - Binary strings with a
    variable length up to 2^31-1
    (2,147,483,647) bytes.

Is there a really big technical difference between VARBINARY(MAX) and IMAGE data types?

If there is a difference: do we have to customize how ADO.NET inserts and updates image data field in SQL Server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

如此安好 2024-10-07 17:50:05

它们存储相同的数据:仅此而已。

image”已被弃用,并且具有一组有限的与其配合使用的功能和操作。 varbinary(max) 可以像较短的 varbinary 一样进行操作(textvarchar(max) 也是如此)。

不要在任何新项目中使用image:只需在此处搜索人们因功能有限而使用imagetext 数据类型的问题。

SO 的示例:一个两个

They store the same data: this is as far as it goes.

"image" is deprecated and has a limited set of features and operations that work with it. varbinary(max) can be operated on like shorter varbinary (ditto for text and varchar(max)).

Do not use image for any new project: just search here for the issues folk have with image and text datatypes because of the limited functionality.

Examples from SO: One, Two

绮烟 2024-10-07 17:50:05

我认为从技术上讲它们是相似的,但重要的是要注意文档中的以下内容: :

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

用于存储大型非 Unicode 和 Unicode 字符以及二进制数据的固定和可变长度数据类型。 Unicode 数据使用 UNICODE UCS-2 字符集。

I think that technically they are similar, but it is important to notice the following from the documentation:

ntext, text, and image data types will be removed in a future version of MicrosoftSQL 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.

Fixed and variable-length data types for storing large non-Unicode and Unicode character and >binary data. Unicode data uses the UNICODE UCS-2 character set.

掩于岁月 2024-10-07 17:50:05

它们存储相同的数据:仅此而已。

“image”已弃用,并且具有有限的功能和操作集
与它一起工作。 varbinary(max) 可以像更短的那样进行操作
varbinary(文本和 varchar(max) 同上)。

不要在任何新项目中使用图像:只需在此处搜索问题
由于有限,人们使用图像和文本数据类型
功能。

事实上,VARBINARY可以存储任何可以转换为字节数组的数据,例如文件,这与IMAGE数据类型使用的过程相同,因此,通过从这个角度来看,这两种数据类型都可以存储相同的数据。
但是 VARBINARY 有一个大小属性,而 IMAGE 接受不超过数据类型限制的任何大小,因此当使用 IMAGE 数据类型时,您将花费更多的资源来存储相同的数据。
Microsoft® SQL Server® 中,IMAGE 数据类型确实已被弃用,因此您必须使用 VARBINARY 数据类型。

但要小心:Microsoft® SQL Server® CE®(包括最新的 4.0 版本)仍然使用 IMAGE 数据类型,并且这种数据类型可能不会这么快“消失” ,因为在 Compact Edition 版本中,这种数据类型比任何其他数据类型都更能快速存储文件。

They store the same data: this is as far as it goes.

"image" is deprecated and has a limited set of features and operations
that work with it. varbinary(max) can be operated on like shorter
varbinary (ditto for text and varchar(max)).

Do not use image for any new project: just search here for the issues
folk have with image and text datatypes because of the limited
functionality.

In fact, VARBINARY can store any data that can be converted into a byte array, such as files, and this is the same process that IMAGE data type uses, so, by this point of view, both data types can store the same data.
But VARBINARY have a size property, while IMAGE accepts any size up to the data type limits, so when using IMAGE data type, you will spend more resources to store the same data.
In a Microsoft® SQL Server®, the IMAGE data type is really deprecated, then you must bet in VARBINARY data type.

But be carefull: The Microsoft® SQL Server® CE® (including the latest 4.0 version) still using IMAGE data type and probably this data type will not "disappears" so soon, because in Compact Edition versions, this data type is better than any other to fast files storage.

醉城メ夜风 2024-10-07 17:50:05

我无意中发现了他们之间的一处区别。您可以将字符串插入图像类型,但不能插入 varbinary。也许这就是 MS 不推荐使用图像类型的原因,因为用字符串设置图像确实没有意义。

I inadvertently found one difference between them. You can insert a string into an image type but not into a varbinary. Maybe that's why MS is deprecating the image type as it really doesn't make sense to set an image with a string.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文