concept

Generated columns

A generated column derives its value from an expression over permitted inputs. SQLite supports virtual and stored variants; constraints on expressions and schema changes vary by engine.

Formal Syntax & Structure

sql syntaxsql
column_name INTEGER GENERATED ALWAYS AS (expression) VIRTUAL

Working Example

Example Snippetsql
CREATE TABLE t(q INTEGER,p INTEGER,total INTEGER GENERATED ALWAYS AS(q*p) VIRTUAL); INSERT INTO t(q,p) VALUES(2,150); SELECT total FROM t;
SQL Reference