public inbox for [email protected]  
help / color / mirror / Atom feed
From: Igor Korot <[email protected]>
To: pgsql-generallists.postgresql.org <[email protected]>
Subject: Documentation weirdness
Date: Sun, 1 Mar 2026 19:38:35 -0600
Message-ID: <CA+FnnTzeE30E4kfK4=+MLe4DBORu4CdYvPQgWUYakRxfwsbEtg@mail.gmail.com> (raw)

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.






reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Documentation weirdness
  In-Reply-To: <CA+FnnTzeE30E4kfK4=+MLe4DBORu4CdYvPQgWUYakRxfwsbEtg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox