Re: Documentation weirdness - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Documentation weirdness
Date
Msg-id 125e4f73-52bc-495c-95ac-7256656cbb80@aklaver.com
Whole thread Raw
In response to Documentation weirdness  (Igor Korot <ikorot01@gmail.com>)
List 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.klaver@aklaver.com



pgsql-general by date:

Previous
From: Igor Korot
Date:
Subject: Documentation weirdness
Next
From: "David G. Johnston"
Date:
Subject: Re: Documentation weirdness