問題描述
我想在我的 SQL Server 中存儲一個字節數組.您建議使用哪種數據類型或插入前操作來存儲這些數據?
我不希望這些 byte[]
的長度超過 1024.
varbinary(1024)
正是您要找的.??p>
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 數據類型來存儲字節 []的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!