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 textRelated terms
- STRICT table — A SQLite table declared with the STRICT keyword, which rejects any value that does not match its column's declared type.
- storage class — In SQLite, the actual kind of a stored value: NULL, INTEGER, REAL, TEXT or BLOB.
- data type — The kind of a value, such as a whole number, text or a date, which decides what you can do with it and how it compares and sorts.
Taught in
- Data Types And What To Choose — PostgreSQL, Indexing & Relational Data Modeling
- Where PostgreSQL Differs From SQLite — PostgreSQL, Indexing & Relational Data Modeling