SQLite 声明数据可以表示为 Unix 时间戳或日期。文本更具可读性,但整数占用的行数据和索引数据更少。
http://www.sqlite.org/datatype3.html
CREATE TABLE testDate (a DATETIME);
INSERT INTO testDate VALUES('1999-12-31 15:00:00');
INSERT INTO testDate VALUES(946652400); -- We will store one format or the other (not both)
SELECT typeof ( a ) FROM testDate;
'text'
'integer'
我们的查询就像
SELECT * FROM testDate
WHERE a > '1990-12-31 15:00:00'
或者
SELECT * FROM testDate
WHERE a > 926652400
文本日期的索引是否仍然有效,是否会有任何重大的性能损失?