Composite types
Composite type
set of named attributes (fields)
same as a table row, but without constraints
Creating a composite type
explicit declaration of a new type
implicitly when a table is created
record: a placeholder composite type
Using a composite type
attributes as scalar values
operations on composite type values: comparison, check for NULL,
use with subqueries
A composite type represents a set of attributes, with each attribute having its
own name and type. A composite type is similar to a table row in many
ways. It is often called a record (similar to a stru ct ure in C-like languages).
https://postgrespro.com/docs/postgresql/17/rowtypes
A composite type is a database object. When it is declared, a new type is
registered in the system catalog, making it a full-fledged SQL type. A table
creation automatically produces a composite type with the same name. This
type represents the row of the table. An important difference is that
composite types do not have constraints.
https://postgrespro.com/docs/postgresql/17/sql-createtype
Composite type attributes can be used as regular scalar values (although
each attribute can also be of a composite type itself).
A composite type can be used just like any other SQL type; for example,
you can create table columns of this type. Composite values can be
compared, checked for NULL, used with subqueries in clauses like IN,
ANY/SOME, ALL.
https://postgrespro.com/docs/postgresql/17/functions-comparisons
https://postgrespro.com/docs/postgresql/17/functions-subquery