On 3/1/26 5:38 PM, Igor Korot wrote:
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]
What the above is telling you is that PK can be defined as part of the
column definition:
some_fld some_type PRIMARY KEY
or as part of the overall table definition:
CREATE TABLE
...
some_fld some_type,
other_fld other_type'
...
PRIMARY KEY (some_fld, other_fld);
Look at the top of documentation under:
"where column_constraint is:"
and
"and table_constraint is:"
respectively.
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.
--
Adrian Klaver
[email protected]