Materialize or compute a derived value from another column.
Section: Create tables and constraints
Create a generated column
sql
sql
CREATE TABLE events (
id INTEGER PRIMARY KEY,
payload TEXT NOT NULL,
event_type TEXT GENERATED ALWAYS AS (json_extract(payload, '$.type')) STORED
);Explanation
Generated columns are handy with JSON payloads and can be indexed when stored.
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