Search Postgresql Archives

Re: How serial primary key numbers are assigned

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.klaver@xxxxxxxxxxx





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux