Re: How serial primary key numbers are assigned

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: How serial primary key numbers are assigned
Date: 2019-04-04 18:35:58
Message-ID: 4d9d29eb-e99c-91b3-381d-f43b36ee24af@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 4/4/19 11:27 AM, Rich Shepard wrote:
> On Thu, 4 Apr 2019, Adrian Klaver wrote:
>
>> See:
>> https://www.postgresql.org/docs/11/sql-createsequence.html
>
> Thanks, Adrian.
>
> My web searches did not find this URL, only results on how to set up
> automatic serial id generation.

Well serial is basically a macro for:

https://www.postgresql.org/docs/11/datatype-numeric.html#DATATYPE-SERIAL

"CREATE SEQUENCE tablename_colname_seq;
CREATE TABLE tablename (
colname integer NOT NULL DEFAULT nextval('tablename_colname_seq')
);
ALTER SEQUENCE tablename_colname_seq OWNED BY tablename.colname;
"

>
> Regards,
>
> Rich
>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2019-04-04 19:01:26 Re: query logging of prepared statements
Previous Message Rich Shepard 2019-04-04 18:27:37 Re: How serial primary key numbers are assigned