SQLite generated columns compute a value from other columns in the row
Answer: A generated column, sometimes also called a computed column, stores or exposes a value that is a function of other columns in the same row. You can read generated columns, but their values can not be directly written. To change a generated column's value, modify the other columns used to calculate the generated column.
Syntax
GENERATED ALWAYSkeywords that designate the column-constraintVIRTUALversus STORED columns, as in the syntax sectionSTOREDversus VIRTUAL columns, as in the syntax sectionPRIMARY KEYan ordinary column in that example, not a generated column
Syntactically, generated columns are designated using a GENERATED ALWAYS column-constraint. The example has three ordinary columns and two generated columns.
Adding a generated column
Verify that constraints are still satisfied. This requires a scan of the entire table if: the new column has a CHECK constraint, or the new column is a NOT NULL generated column, or the table is STRICT and the new generated column has a type other than ANY.
See also
Claims
- id: C1 claim: A generated column's value is a function of other columns in the same row and cannot be written directly. source: S1 evidence: "values are a function of other columns in the same row."
- id: C2 claim: Syntax uses a GENERATED ALWAYS column constraint, as VIRTUAL or STORED. source: S1 evidence: "generated columns are designated using a \"GENERATED ALWAYS\" column-constraint"
- id: C3 claim: Adding a NOT NULL generated column, or a typed generated column on a STRICT table, forces a full-table constraint check. source: S2 evidence: "the new column is a NOT NULL generated column"
Sources
- [S1] Generated Columns. SQLite. https://www.sqlite.org/gencol.html . License: Public-Domain. Accessed 2026-11-20.
- [S2] alter.c generated column checks. SQLite. https://raw.githubusercontent.com/sqlite/sqlite/master/src/alter.c . License: Public-Domain. Accessed 2026-11-20.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: SQLite, Generated Columns; SQLite, alter.c generated column checks. Public-Domain; Public-Domain. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: SQLite, Generated Columns; SQLite, alter.c generated column checks. Public-Domain; Public-Domain.
Cite this
iinventedlight. 2026. "SQLite generated columns compute a value from other columns in the row." iinventedlight Library, iil:note:4appbf1p, version of 2026-11-20. https://iinventedlight.com/library/notes/sqlite-generated-columns/. License: CC-BY-4.0.
@misc{iil_note_4appbf1p,
author = {{iinventedlight}},
title = {{SQLite generated columns compute a value from other columns in the row}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-20},
url = {https://iinventedlight.com/library/notes/sqlite-generated-columns/},
note = {Permanent ID iil:note:4appbf1p. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- sqlite-generated-columns.table.json (table; CC-BY-4.0)
- sqlite-generated-columns.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/sqlite-generated-columns.md.