Re: Equivalent for AUTOINCREMENT?

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Michelle Konzack *EXTERN*" <linux4michelle(at)tamay-dogan(dot)net>, "Nikolas Everett" <nik9000(at)gmail(dot)com>
Cc: "pgSQL - General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Equivalent for AUTOINCREMENT?
Date: 2008-11-05 14:01:02
Message-ID: D960CB61B694CF459DCFB4B0128514C202ACF95D@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2008-11-05 14:51:30 Re: COPY TO duplicates "\" signs
Previous Message Willy-Bas Loos 2008-11-05 13:36:49 [pgsql-general] cant find postgres executable after initdb