Search Postgresql Archives

Re: Equivalent for AUTOINCREMENT?

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

 



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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[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