Why does HEX(10) differ from the byte 0A?
hex renders the bytes of its input as hexadecimal text. Numeric inputs are first converted to their textual representation.
SQLite example and interpretation
Integer ten contributes the bytes for the characters one and zero. A one-byte blob containing 0A renders as 0A. Check the bound type when inspecting binary data.
SELECT hex(10),hex(X'0A');Result [["3130", "0A"]]
中文
为什么 HEX(10) 得不到十六进制的 0A?
hex 将输入按 BLOB 解释并输出十六进制文本。数值输入先转换成数值的文本表示。
SQLite 示例与适用条件
整数 10 经文本转换得到字符 1 和 0 的字节;真正的单字节 0A 才输出 0A。校验二进制字段时要确认绑定类型。
SELECT hex(10),hex(X'0A');结果 [["3130", "0A"]]