如何在sqlite中找到二进制blob的长度(大小)

我有一个sqlite表包含一个BLOB文件,但需要做一个大小/长度检查上的blob,我该怎么做?

根据一些文档,我发现,使用length(blob)将无法工作,因为length()只适用于文本,并将在第一个NULL后停止计数。我的经验测试表明这是真的。

我使用sqlite 3.4.2

更新:

因此,从sqlite 3.7.6看来,尽管length()函数返回正确的blobs值 – 我检查了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.
没有这个问题,但你可以尝试长度(hex(glob))/ 2

更新(2012年8月):对于sqlite 3.7.6(2011年4月12日发布)和更高版本,长度(blob_column)同时适用于文本和二进制数据。

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能