STRICT tables in SQL
SQLite's flexible typing is a feature until the day you would rather it refused.
CREATE TABLE readings (
id INTEGER PRIMARY KEY,
sensor TEXT NOT NULL,
celsius REAL NOT NULL,
payload ANY,
taken_at TEXT NOT NULL
) STRICT;
INSERT INTO readings (sensor, celsius, taken_at)
VALUES ('kitchen', 21.5, '2026-07-29 08:00:00');
How it works
- A
STRICTtable rejects a value whose type does not match the column. - Only a fixed set of type names is allowed: INT, INTEGER, REAL, TEXT, BLOB, ANY.
ANYopts one column back into flexible typing, on purpose.
Keywords and builtins used here
ANYCREATEINSERTINTEGERINTOKEYNOTNULLPRIMARYREALSTRICTTABLETEXTVALUES
The run, in numbers
- Lines
- 10
- Characters to type
- 237
- Tokens
- 50
- Three-star pace
- 85 tpm
At the three-star pace of 85 tokens a minute, this run takes about 35 seconds.
Step 4 of 5 in Constraints, step 4 of 16 in Schema & constraints.