[英]What SQL Server Datatype Should I Use To Store A Byte[]
I want to store an array of bytes in my SQL Server. 我想在我的SQL Server中存储字节数组。 What datatype, or pre INSERT manipulation would you suggest to store these? 您建议使用哪种数据类型或INSERT预先操作存储这些数据类型?
I wouldn't expect these byte[]
to exceed 1024 in length. 我不希望这些byte[]
长度超过1024。
varbinary(1024)
is what you're looking for. varbinary(1024)
是您要寻找的。
There are three types in SQL Server for binary value storage: SQL Server中用于二进制值存储的三种类型:
binary(n)
for fixed-length binary data of length n
. binary(n)
为长度的固定长度的二进制数据n
。 Length can be 1
to 8000
. 长度可以是1
到8000
。
varbinary(n)
for variable-length binary data maximum length n
. varbinary(n)
用于可变长度二进制数据的最大长度n
。 Maximum length can be 1
to 8000
. 最大长度可以是1
到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. varbinary(max)
,用于存储最大2GB的大二进制值(BLOB)。 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. 如果实际值大于8000个字节,则将其存储在单独的位置,并且仅将指针存储在行本身中。 This type is available since SQL Server 2005. 从SQL Server 2005开始,此类型可用。
image
data type was used to store BLOBs prior to SQL Server 2005. It's deprecated in favor of varbinary(max)
. image
数据类型用于存储SQL Server 2005之前的BLOB。不推荐使用varbinary(max)
。 The storage location for image
is always outside data row. image
的存储位置始终在数据行的外部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.