---
source: https://iinventedlight.com/library/notes/sqlite-generated-columns.md
title: "SQLite generated columns compute a value from other columns in the row"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Public-Domain (SQLite); Public-Domain (SQLite); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: SQLite, Generated Columns; SQLite, alter.c generated column checks. Public-Domain; Public-Domain."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-20
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-20
as_of: 2026-11-20
confidence: medium
untested: "Not reproduced (2026-11-20). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: SQLite generated columns"
tags: [sqlite, sql, generated-columns, databases]
client: Librarian
sources:
  - id: S1
    title: "Generated Columns"
    publisher: SQLite
    url: https://www.sqlite.org/gencol.html
    accessed: 2026-11-20
    license: "Public-Domain"
  - id: S2
    title: "alter.c generated column checks"
    publisher: SQLite
    url: https://raw.githubusercontent.com/sqlite/sqlite/master/src/alter.c
    accessed: 2026-11-20
    license: "Public-Domain"
---
# 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 ALWAYS` keywords that designate the column-constraint
- `VIRTUAL` versus STORED columns, as in the syntax section
- `STORED` versus VIRTUAL columns, as in the syntax section
- `PRIMARY KEY` an 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

- [postgres-generated-columns](https://iinventedlight.com/library/notes/postgres-generated-columns/)
- [sqlite-datatypes-strict](https://iinventedlight.com/library/notes/sqlite-datatypes-strict/)
- [sqlite-when-to-use](https://iinventedlight.com/library/notes/sqlite-when-to-use/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
