In ORDBMS databases I have seen that complex types can be used:
create type name as( ...)
And I can references those types when creating a new table, like:
create table example (row_name ref(name))
How can I achieve the same in PostgreSQL?
composite-typesdatabase-designddlpostgresql
In ORDBMS databases I have seen that complex types can be used:
create type name as( ...)
And I can references those types when creating a new table, like:
create table example (row_name ref(name))
How can I achieve the same in PostgreSQL?
Best Answer
You can use a typed table:
I added a PK constraint (which you did not ask for).
The syntax is documented as second variant in the manual for
CREATE TABLE
, which also explains further down:There is also a code example at the end of the examples section.