我们如何对SQL二进制数据类型执行操作? [英] How do we perform operations on SQL binary data type?
问题描述
您好,是否可以对MySQL / SqlServer二进制数据类型进行算术运算?
例如,我有一个256位的值存储在列中。 / p>
我要选择 10000000000
(1024)和 10011010100111110101
(633333)。
数据库是否提供此功能?
位整数列是唯一的选择范围从x到y的方法?
'二进制数据类型'根据定义对数据库不透明。如果您使用此类型,则由应用程序来处理。
如果您希望数据库处理/索引/查询您的数据,选择它理解的数据类型。对于SQL Server,BIGINT为8字节(64位),NUMERIC可以转到38位(〜126位)。在MySQL中,DECIMAL / NUMERIC可以转到64或65位数字(〜212位)。
如果你真的有一个真正的要求, 实际重要段落成他们自己的列&查询这些。
在最钝的&不知道的解决方案情况,可以将您的256位块划分为2或4个字;但如果你有任何实际需求,你应该能够找出更具体的商业利益部分。
Hi all is it possible to do arithmetic operations on MySQL / SqlServer binary data type?
For example, I have 256-bit values stored within a column.
And I want to select values between 10000000000
(1024) and 10011010100111110101
(633333).
Do databases provide this functionality?
Or is storing it as 4 64-bit integer column the only way to select a range from x to y?
'Binary datatype'/ binary object/ BLOB is opaque to the database, by definition. If you use this type it's up to the application to process it.
If you want the database to process/index/query your data, pick a datatype it understands. For SQL Server, BIGINT is 8 bytes (64 bits) and NUMERIC can go to 38 digits (~ 126 bits). In MySQL, DECIMAL/NUMERIC can go to 64 or 65 digits (~ 212 bits).
And if you do actually have a real requirement here, you can "factor out" the actual significant segments into their own columns & query on those.
In the most blunt & uninformed workaround case, that could be dividing your 256-bit chunk into 2 or 4 words; but if you have any kind of real requirement, you should be able to identify more specific sections which are of business interest.
这篇关于我们如何对SQL二进制数据类型执行操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!