What SQL Server Datatype Should I Use To Store A Byte[](我应该使用什么 SQL Server 数据类型来存储字节 [])
问题描述
我想在我的 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 数据类型来存储字节 []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我应该使用什么 SQL Server 数据类型来存储字节
基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
