SQLite 3.37.0, released on November 27, 2021, gives application teams a way to reject values that cannot be converted to a column’s declared type. Its new STRICT option applies table by table, rather than changing an entire database’s typing rules. For an import pipeline, the distinction is rejection versus conversion: STRICT still allows a value to be converted without loss. [S1][S2]

Developers opt in by placing STRICT after the closing parenthesis of a CREATE TABLE statement. Every column must name one of six types: INT, INTEGER, REAL, TEXT, BLOB or ANY. For a non-ANY column, SQLite attempts to convert the value to the declared type and raises SQLITE_CONSTRAINT_DATATYPE if it cannot do so without loss. An integer column can therefore still accept the text '123' as integer 123. The difference is an input such as 'xyz': an ordinary integer column can retain that text, while the STRICT rule rejects it. A non-key column can still contain NULL unless NOT NULL is declared. [S2]

ANY provides a deliberate exception for columns that need to hold different kinds of data, but its behavior depends on the table. The release documentation shows the text '000123' staying text, with its leading zeros intact, in a STRICT table’s ANY column. The same input becomes integer 123 in an ordinary table’s ANY column. In a STRICT table, ANY preserves the incoming value and datatype without coercion; a NOT NULL constraint still applies if one is declared. That distinction matters when an import must preserve numeric-looking text rather than normalize it into a number. [S2]

The file format is unchanged; older tools can still fail to open the database. SQLite versions before 3.37.0 normally report an error because they do not recognize the STRICT keyword in the schema. The documentation describes an older-parser bypass using writable_schema, but that suppresses schema errors without enforcing strict types. It can allow incorrectly typed values into a STRICT table. A file created by the new release can still work with older SQLite versions when it contains neither STRICT tables nor other features newer than those versions. [S2]

A practical rollout test would exercise valid values, convertible text, invalid text and any fields whose leading zeros must survive. Check the SQLite versions used by maintenance tools as well as the application before introducing STRICT tables; the compatibility boundary applies to readers and writers of the same file. SQLite’s PRAGMA integrity_check and PRAGMA quick_check inspect the stored column types in STRICT tables and report errors. [S2]

Source documents

  1. SQLite Release 3.37.0 On 2021-11-27https://www.sqlite.org/releaselog/3_37_0.html
  2. STRICT Tables — SQLite 3.37.0 documentation editionhttps://www.sqlite.org/2021/sqlite-doc-3370000.zip