type affinity

SQLite's rule that a column's declared type is only a preference: values are converted when sensible and otherwise stored as they are.

In more detail

Insert the word banana into a SQLite column declared INTEGER and it is stored as text, where PostgreSQL, MySQL and SQL Server would refuse it. This loose typing is unique to SQLite. Declaring the table STRICT turns the preference into a rule.

Example

CREATE TABLE loose (n INTEGER); INSERT INTO loose VALUES ('banana');  -- accepted, stored as text

Related terms

Taught in

References