public inbox for [email protected]  
help / color / mirror / Atom feed
From: Adrian Klaver <[email protected]>
To: Igor Korot <[email protected]>
To: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: Documentation weirdness
Date: Sun, 1 Mar 2026 17:52:42 -0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+FnnTzeE30E4kfK4=+MLe4DBORu4CdYvPQgWUYakRxfwsbEtg@mail.gmail.com>
References: <CA+FnnTzeE30E4kfK4=+MLe4DBORu4CdYvPQgWUYakRxfwsbEtg@mail.gmail.com>

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]






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], [email protected]
  Subject: Re: Documentation weirdness
  In-Reply-To: <[email protected]>

* 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