Hi, ALL,
I'm looking at https://www.postgresql.org/docs/current/sql-createtable.html
and see some weird stuff.
When I try to search for "PRIMARY KEY" I eventually hit following:
[quote]
PRIMARY KEY (column constraint)
PRIMARY KEY ( column_name [, ... ] [, column_name WITHOUT OVERLAPS ] )
[ INCLUDE ( column_name [, ...]) ] (table constraint)
[/quote]
Now I want to check what "column_constraint" is.
Going all the way up and start searching I see that its:
[quote]
where column_constraint is:
[ CONSTRAINT constraint_name ]
{ NOT NULL [ NO INHERIT ] |
NULL |
CHECK ( expression ) [ NO INHERIT ] |
DEFAULT default_expr |
GENERATED ALWAYS AS ( generation_expr ) [ STORED | VIRTUAL ] |
GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( sequence_options ) ] |
UNIQUE [ NULLS [ NOT ] DISTINCT ] index_parameters |
PRIMARY KEY index_parameters |
REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL |
MATCH SIMPLE ]
[ ON DELETE referential_action ] [ ON UPDATE referential_action ] }
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY
IMMEDIATE ] [ ENFORCED | NOT ENFORCED ]
[/quote]
which already contains "PRIMARY KEY".
And so according to the documentation one can write:
CREATE TABLE foo( id SERIAL PRIMARY KEY PRIMARY KEY, ... );
which unfortunately will be illegal.
Or not?
Thank you.