关于sqlite中的BLOB我有以下问题:
我问这个是因为我想知道我是否应该实现在其他列中设置BLOBs大小的触发器,如果我可以动态获取大小而没有sqlite读取BLOB的性能损失.
从来源:
** In an SQLite index record, the serial type is stored directly before
** the blob of data that it corresponds to. In a table record, all serial
** types are stored at the start of the record, and the blobs of data at
** the end. Hence these functions allow the caller to handle the
** serial-type and data blob seperately.
**
** The following table describes the various storage classes for data:
**
** serial type bytes of data type
** -------------- --------------- ---------------
** 0 0 NULL
** 1 1 signed integer
** 2 2 signed integer
** 3 3 signed integer
** 4 4 signed integer
** 5 6 signed integer
** 6 8 signed integer
** 7 8 IEEE float
** 8 0 Integer constant 0
** 9 0 Integer constant 1
** 10,11 reserved for expansion
** N>=12 and even (N-12)/2 BLOB
** N>=13 and odd (N-13)/2 text
Run Code Online (Sandbox Code Playgroud)
换句话说,blob 大小是串行的,它的长度只是“(serial_type-12)/2”。
此序列存储在实际 blob 之前,因此您无需读取 blob 即可获取其大小。
调用 sqlite3_blob_open 然后调用 sqlite3_blob_bytes 来获取这个值。
| 归档时间: |
|
| 查看次数: |
1215 次 |
| 最近记录: |