Re: Best way to create unique primary keys across schemas?

From: panam <panam(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Best way to create unique primary keys across schemas?
Date: 2012-01-24 22:54:56
Message-ID: 1327445696484-5428997.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Chris Angelico wrote
>
> I would recommend using an explicit sequence object rather than
> relying on odd behavior like this; for instance, if you now drop
> public.tbl, the sequence will be dropped too. However, what you have
> there is going to be pretty close to the same result anyway.
>
Oops, thanks for the warning. Any means to prevent accidently dropping the
sequence by deleting the corresponding "root"-table?
What do you mean with "explicit sequence object"? An own sequence for each
table per schema?

Chris Angelico wrote
>
> I think it's possible
> to reset a sequence object to start producing lower numbers again,
> while your table still has some higher numbers in it (of course being
> careful not to get pkey collisions).
>
Yes, this is definitely possible
(http://www.postgresql.org/docs/9.1/static/sql-altersequence.html)

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Best-way-to-create-unique-primary-keys-across-schemas-tp5165043p5428997.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2012-01-24 23:23:18 Re: Best way to create unique primary keys across schemas?
Previous Message jonesd 2012-01-24 17:08:10 Document routing workflow database design