0

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).

0

1 Answer 1

2

It makes no sense to have an identity column in a data type. After all, a data type does not hold data. So yes, that is not possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.