My impression is that each PostgreSQL table has a corresponding composite type associated with it. But it seems that the PostgreSQL identity column cannot be used in a CREATE TYPE
statement:
=> CREATE TYPE _t_type AS (id bigint GENERATED ALWAYS AS IDENTITY);
ERROR: syntax error at or near "GENERATED"
LINE 1: CREATE TYPE _t_type AS (id bigint GENERATED ALWAYS AS IDENTI...
^
, while it can be used in a CREATE TABLE
:
=> CREATE TABLE _t_table (id bigint GENERATED ALWAYS AS IDENTITY);
CREATE TABLE
Is there a fundamental reason why identity columns cannot or should not be used in CREATE TYPE
statement?
(This is with PostgreSQL 14 beta1).