How do SQLite storage classes differ from declared column types?
Quick answer
A declared column type and a value’s storage class are different things. In ordinary SQLite tables, the declared type determines a type affinity—a preference that may cause conversions, but generally does not restrict values to one storage class. Each value has its own storage class: NULL, INTEGER, REAL, TEXT, or BLOB. STRICT tables enforce types more rigidly, subject to their rules and limitations. [S1]
The question, the details, the next step.
A practical checklist
Record the exact declared type for the column.
Identify whether the table is ordinary or STRICT.
Record the observed storage class for the specific value, separately from the declared type.
Write down the expected and observed results as separate fields.
For STRICT tables, check the applicable documented rules before inferring how a value will be handled.
A few more useful answers
What are SQLite’s five storage classes?
NULL, INTEGER, REAL, TEXT, and BLOB. A storage class describes a value, not merely the type name written in a column definition. [S1]
Does affinity mean SQLite always converts a value to match the declared type?
No. Affinity expresses a storage preference and may cause conversions; in ordinary tables it generally does not restrict a column to a single storage class. [S1]
Does the information here give the full rules for STRICT tables?
No. It establishes that STRICT tables provide more rigid type enforcement and notes their availability since SQLite 3.37.0, but it does not give their detailed rules or limitations. [S1]
Sources
References used for this guide.
- [S1] SQLite Datatypes: storage classes and type affinity sqlite.org · Checked
