SQLITE date no type checked

后端 未结 2 906
悲&欢浪女
悲&欢浪女 2021-01-18 21:35

I just tested sqlite and created a table.

$sqlite3 plop.db

sqlite> CREATE TABLE t (d DATE);

sqlite> INSERT INTO t (d) VALUES (\'Hello\');

sqlite>         


        
2条回答
  •  失恋的感觉
    2021-01-18 22:00

    SQLite DATE type has NUMERIC affinity. Despite its name, the NUMERIC affinity allows storing data of all five storage classes (NULL, INTEGER, REAL, TEXT, and BLOB). A column that has NUMERIC affinity (e.g. a DATE column) tries to convert any text data to INTEGER and REAL first. If this conversion is possible, it stores data using INTEGER or REAL storage classes respectively. If conversion is not possible, the data is stored using TEXT storage class. And this is exactly what happened in your case. See http://www.sqlite.org/datatype3.html#affinity

提交回复
热议问题