简体   繁体   English

我应该使用哪种SQL Server数据类型来存储字节[]

[英]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 . 长度可以是18000
varbinary(n) for variable-length binary data maximum length n . varbinary(n)用于可变长度二进制数据的最大长度n Maximum length can be 1 to 8000 . 最大长度可以是18000
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.

相关问题 我应该使用什么数据类型来存储SQL Server中的自定义值 - What datatype should I use to store custom value in SQL Server 在SQL Server中应使用哪种数据类型存储数组 - What datatype should be used to store an array in the SQL Server 我应该对文本字段使用哪种SQL Server数据类型,而该字段会被JOINED,“ LIKE'd”和被查询很多? - What SQL Server DataType should I use for a Text field which will be JOINED, “LIKE'd” and Queried against a lot? 使用SQL Server向数据表添加包含空值的列时,我应该使用哪种数据类型? - What datatype should I use when adding a column that will contain a null to a Datatable with SQL Server? 我应该使用什么数据类型在 SQL Azure 数据库中保存文件? - What datatype should I use for saving a file in a SQL Azure database? 应该使用哪种 SQL 服务器数据类型? - What kind of SQL Server datatype should be used? SQL Server 2008使用什么DataType存储哈希密码 - SQL Server 2008 what DataType to store a hashpassword in 我应该使用什么数据类型变量来存储时间,以便我可以将它加载到我的数据库中 - What datatype variable should I use to store time so I can load it in my database 应该使用什么样的数据类型来存储哈希值? - What kind of datatype should one use to store hashes? 我应该使用smallint还是numeric(4,0)在SQL Server中存储一年 - Should I use smallint or numeric(4,0) to store a year in SQL Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM