Search Postgresql Archives

Re: auto-increment column

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

 



On 10/04/2011 08:05 AM, Robert Buckley wrote:
> Thanks for the replies,
> 
> I have one question regarding this comment...
> 
> "You also need to add a DEFAULT expression and optionally
> make the sequence owned by the column:"
> 
> What difference does it make if a table "owns" a sequence of not?...does
> this contraint the use of the sequence to ONLY that one table?
> 
> The sequence will only be used to auto-increment the id column in order
> to have an automatic primary key. Could I then somehow use the sequence
> for all tables which need this?

Making the table own the sequence causes the sequence to be dropped if
the table is dropped.  Making the sequence owned by the table happens
automatically if you had originally created the column with SERIAL
instead of adding the sequence with ALTER TABLE, but is not entirely
necessary.

That said, I'd think twice before using a sequence for more than one
table (unless they were part of an inheritance/partitioning scheme).

Joe

-- 
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