我有一个包含BLOB文件的sqlite表,但需要对blob进行大小/长度检查,我该怎么做?如何在sqlite中找到二进制blob的长度(大小)
根据我找到的一些文档,使用长度(blob)将不起作用,因为length()仅适用于文本,并会在第一个NULL之后停止计数。我的实证检验显示这是真实的。
我使用SQLite 3.4.2
更新:
那么作为的SQLite 3.7.6看起来好像长度()函数返回的斑点正确的价值 - 我查sqlite的各种更改日志,但没有看到该版本已更正。
从SQLite的3.7.6:
payload_id|length(payload)|length(hex(payload))/2 1807913|194|194 1807914|171|171
的documentation改为反映这一点。
length(X) The length(X) function returns the length of X in characters if X is a string, or in bytes if X is a blob. If X is NULL then length(X) is NULL. If X is numeric then length(X) returns the length of a string representation of X.
对于二进制blob?这将违反SQLite文档,它将blob视为文本,并且只有在找到'\ 0`字符之前length()才是准确的。 – Petriborg 2010-09-24 10:55:00