我想在我的 SQL Server 中存储一个字节数组.您建议使用哪种数据类型或插入前操作来存储这些数据?
我不希望这些 byte[]
的长度超过 1024.
varbinary(1024)
正是您要找的.
SQL Server 中二进制值存储有三种类型:
binary(n)
用于长度为 n
的固定长度二进制数据.长度可以是1
到8000
.varbinary(n)
用于可变长度的二进制数据最大长度n
.最大长度可以是 1
到 8000
.
以上类型将存储在行数据本身中.varbinary(max)
用于存储高达 2GB 的大二进制值 (BLOB).如果实际值大于 8000 字节并且仅指针存储在行本身中,则实际值存储在单独的位置.此类型自 SQL Server 2005 起可用.
image
数据类型在 SQL Server 2005 之前用于存储 BLOB.它已被弃用,取而代之的是 varbinary(max)
.image
的存储位置总是在数据行之外.
I want to store an array of bytes in my SQL Server. What datatype, or pre INSERT manipulation would you suggest to store these?
I wouldn't expect these byte[]
to exceed 1024 in length.
varbinary(1024)
is what you're looking for.
There are three types in SQL Server for binary value storage:
binary(n)
for fixed-length binary data of length n
. Length can be 1
to 8000
.
varbinary(n)
for variable-length binary data maximum length n
. Maximum length can be 1
to 8000
.
Above types will be stored in the row data itself.
varbinary(max)
which is used to store large binary values (BLOBs) up to 2GB. The actual value is stored in a separate location if it's larger than 8000 bytes and just a pointer is stored in the row itself. This type is available since SQL Server 2005.
image
data type was used to store BLOBs prior to SQL Server 2005. It's deprecated in favor of varbinary(max)
. The storage location for image
is always outside data row.
这篇关于我应该使用什么 SQL Server 数据类型来存储字节 []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!