Validate allowed values at the database layer.
Section: Create tables and constraints
Use a CHECK constraint
sql
sql
CREATE TABLE subscriptions (
id INTEGER PRIMARY KEY,
plan TEXT NOT NULL CHECK (plan IN ('free','premium','team')),
status TEXT NOT NULL CHECK (status IN ('active','canceled','past_due'))
);Explanation
CHECK constraints help protect data quality even when multiple apps write to the same file.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Create tables and constraints
Create a basic table
Define a rowid-backed table with primary key and timestamps.
Create a generated column
Materialize or compute a derived value from another column.