Re: Equivalent for AUTOINCREMENT? - Mailing list pgsql-general

From Albe Laurenz
Subject Re: Equivalent for AUTOINCREMENT?
Date
Msg-id D960CB61B694CF459DCFB4B0128514C202ACF95D@exadv11.host.magwien.gv.at
Whole thread Raw
In response to Re: Equivalent for AUTOINCREMENT?  (Michelle Konzack <linux4michelle@tamay-dogan.net>)
List pgsql-general
Michelle Konzack wrote:
> > I think you want a sequence. Give the serial number the type
bigserial or
> > serial.  See
> >
http://www.postgresql.org/docs/current/static/functions-sequence.html
for
> > more.
>
> OK, thats cool...  I have found an example in
"sql-createsequence.html"
>
> CREATE SEQUENCE serial START 1;
>
> INSERT INTO distributors VALUES (nextval('serial'), 'nothing');
>
> But there is one thing not clear:
>
> Du I need to create a SEQUENCE for each table or do I need only  ONE
of
> if and can use it independant on differnt tables?

You can use one sequence for many tables.

If you follow the advice by Nikolas Everett and use a "serial" column,
that would create one dedicated sequence per serial column.

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: "Willy-Bas Loos"
Date:
Subject: [pgsql-general] cant find postgres executable after initdb
Next
From: "Albe Laurenz"
Date:
Subject: Re: COPY TO duplicates "\" signs