Skip to content

Column

Defines a column in a table

Properties

Property Type Required Description
name string yes The column name.
data_type string yes The column data type.
nullable boolean — Column is NULLABLE when True. Defaults to True. Default: true.
not_null_constraint object — The parts of the column's NOT NULL constraint that nullable cannot express (PostgreSQL 18 and later, where NOT NULL is a named constraint). Present only when the name is not the one PostgreSQL generates, <table>_<column>_not_null cut to 63 bytes, or when the constraint is NO INHERIT. When two columns of the table cut to the same name, PostgreSQL adds a number to the name of the second column (_not_null1), and that name is generated too. nullable stays authoritative for whether the constraint exists at all.
default boolean | number | string — Default value for the column.
collation string — Assigns a collation to the column (which must be of a collatable data type). If not specified, the column data type's default collation is used.
check_constraint string — Specifies an expression producing a Boolean result which new or updated rows must satisfy for an insert or update operation to succeed.
generated object — Options for specifying a generated column.
storage PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT — How the column's values are stored (SET STORAGE), when it differs from the type's default.
compression string — The compression method for the column's values (SET COMPRESSION).
statistics integer — The column's statistics target (SET STATISTICS).
options object — Per-column options such as n_distinct (ALTER COLUMN ... SET (...)).
comment string — An optional comment about the column.
security_labels security_labels — Security Labels.

not_null_constraint

The parts of the column's NOT NULL constraint that nullable cannot express (PostgreSQL 18 and later, where NOT NULL is a named constraint). Present only when the name is not the one PostgreSQL generates, <table>_<column>_not_null cut to 63 bytes, or when the constraint is NO INHERIT. When two columns of the table cut to the same name, PostgreSQL adds a number to the name of the second column (_not_null1), and that name is generated too. nullable stays authoritative for whether the constraint exists at all.

Property Type Required Description
name string — —
no_inherit boolean — Whether the constraint is not inherited by this table's descendants.

generated

Options for specifying a generated column

Property Type Required Description
expression string — The expression used to generate the column. Mutually exclusive with the sequence column.
kind stored | virtual — Whether the expression is materialized on write (stored) or evaluated on read (virtual). PostgreSQL 18 makes virtual the default and pg_dump omits the keyword for a virtual column, so the kind is recorded rather than assumed. An absent value means stored, which is what project files written before this attribute existed have always built.
sequence — — Specifies that the generated column value is provided by a sequence. Mutually exclusive with the expression attribute.
sequence_behavior ALWAYS | BY DEFAULT — The clauses ALWAYS and BY DEFAULT determine how the sequence value is given precedence over a user-specified value in an INSERT statement. If ALWAYS is specified, a user-specified value is only accepted if the INSERT statement specifies OVERRIDING SYSTEM VALUE. If BY DEFAULT is specified, then the user-specified value takes precedence.
sequence_options object — The options of an identity column's own sequence. Each is omitted when it holds PostgreSQL's default, so an identity that states none is an ordinary one starting at 1. Distinct from sequence, which names a sequence managed as its own object and is not rendered.

Mutually exclusive forms

Exactly one of these must hold:

  • expression

No other properties are accepted.


Source: schemata/column.yml · Resolved JSON Schema: column.json