Re: Documentation weirdness

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Igor Korot <ikorot01(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Documentation weirdness
Date: 2026-03-02 01:52:42
Message-ID: 125e4f73-52bc-495c-95ac-7256656cbb80@aklaver.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

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
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2026-03-02 02:08:48 Re: Documentation weirdness
Previous Message Igor Korot 2026-03-02 01:38:35 Documentation weirdness