SQLite 中的 INTEGER:带符号的整型,具体取决有存入数字的范围大小,根据大小可以使用1,2,3,4,6,8字节来存储。
在SQLite中,存储分类和数据类型也有一定的差别,如INTEGER存储类别可以包含6种不同长度的Integer数据类型,然而这些INTEGER数据一旦被读入到内存后,SQLite会将其全部视为占用8个字节无符号整型。
INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the magnitude of the value.
The INTEGER storage class, for example, includes 6 different integer datatypes of different lengths. This makes a difference on disk. But as soon as INTEGER values are read off of disk and into memory for processing, they are converted to the most general datatype (8-byte signed integer).
不同长度的 Integer 对应的最大、最小值如下图:
注意, Integer 默认就是 4字节的 int4.
转自:
http://zhiwei.li/text/2009/11/sqlite%E6%94%AF%E6%8C%81%E7%9A%84%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B/
http://libdbi-drivers.sourceforge.net/docs/dbd_sqlite3/x123.html