Sqlite 列被分配了错误的数据类型值

Sqlite column is getting assigned wrong data type value

我在 sqlite 中有一个 table,具有以下架构:

CREATE TABLE message(ITEM_ID TEXT, COUNTRY_ID TEXT, CODES INTEGER);

即使 CODES 是整数,我仍然可以像这样将字符串数据插入 table:

insert into message values(124,'5','R')

我期待 sqlite 的错误。它不应该 return 一个错误吗?

谢谢,

SQLite 不以这种方式限制类型。 SQLite FAQ有话要说;

SQLite uses dynamic typing. It does not enforce data type constraints. Data of any type can (usually) be inserted into any column. You can put arbitrary length strings into integer columns, floating point numbers in boolean columns, or dates in character columns. The datatype you assign to a column in the CREATE TABLE command does not restrict what data can be put into that column.

这与(大多数)其他 SQL 数据库不同,您可能已经注意到,在测试数据库代码时需要格外小心。