| From: | Igor Korot <ikorot01(at)gmail(dot)com> |
|---|---|
| To: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
| Subject: | Documentation weirdness |
| Date: | 2026-03-02 01:38:35 |
| Message-ID: | CA+FnnTzeE30E4kfK4=+MLe4DBORu4CdYvPQgWUYakRxfwsbEtg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrian Klaver | 2026-03-02 01:52:42 | Re: Documentation weirdness |
| Previous Message | Justin Swanhart | 2026-03-01 12:22:26 | Re: Can "on delete cascade" dependency be used in pgdump or similar ? |