{
  "slug": "sqlite-generated-column",
  "term": "SQLite generated column",
  "aliases": [
    "computed column",
    "STORED generated column",
    "VIRTUAL generated column"
  ],
  "definition": "A SQLite generated column derives its value from an expression over columns in the same row, with STORED values materialized on writes and VIRTUAL values evaluated on reads.",
  "note": "Generated expressions require deterministic scalar functions. Generated columns are absent from table_info but included in table_xinfo, whose hidden flag is 2 for virtual and 3 for stored. [generated] [table-xinfo]\n\nIn seven controlled SQLite 3.45.1 observations, changing score(x) from x to x+100 left old STORED values in reopened, reindexed and backup copies while VIRTUAL values changed; integrity_check returned ok throughout. Python SQL-dump replay under the new callback recomputed stored values. Preserve or deliberately migrate the function implementation as well as the database. [experiment]\n\nA further three-case UNIQUE replay experiment changed the callback so two inputs generated the same key. Replay stopped at the second INSERT but left the first in an active transaction; explicit rollback discarded the import, whereas deliberately committing preserved an incomplete one-row table that passed integrity_check. Treat replay success and application completeness as separate acceptance checks. [replay]",
  "related": [
    "sqlite-expression-index",
    "sqlite-integrity-check",
    "backup-verification"
  ],
  "citations": [
    {
      "id": "generated",
      "title": "SQLite: Generated Columns",
      "url": "https://sqlite.org/gencol.html",
      "accessed": "2026-10-18"
    },
    {
      "id": "table-xinfo",
      "title": "SQLite PRAGMA table_xinfo: generated-column flags",
      "url": "https://sqlite.org/pragma.html#pragma_table_xinfo",
      "accessed": "2026-10-18"
    },
    {
      "id": "experiment",
      "title": "Hesela: SQLite stored generated-column controls",
      "url": "https://hesela.com/analyses/sqlite-index-runtime-dependencies/#stored-columns",
      "accessed": "2026-10-18"
    },
    {
      "id": "replay",
      "title": "Hesela: generated-column replay failures and transaction finalization",
      "url": "https://hesela.com/analyses/sqlite-index-runtime-dependencies/#replay-errors",
      "accessed": "2026-10-18"
    }
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [
    "Changing a function implementation can violate the schema's determinism assumption; the controls are not a newly discovered SQLite defect."
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-18",
  "provenance": [
    "Seven designed cases on SQLite 3.45.1 and Python 3.12.3; closed DELETE-journal fixtures, no failure-rate estimate. Full rows, scripts and runtime identity are linked from the analysis.",
    "Three additional UNIQUE-constrained SQL replay controls on the same runtime; explicit rollback and deliberately unsafe commit after an error. Not a crash test or general import-tool guarantee."
  ]
}
