From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | <Robert(dot)Farrugia(at)go(dot)com(dot)mt> |
Cc: | <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: One sequence for different tables |
Date: | 2002-03-11 17:04:10 |
Message-ID: | Pine.LNX.4.30.0203111202400.690-100000@peter.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Robert(dot)Farrugia(at)go(dot)com(dot)mt writes:
> Is it possible to create one sequence to be used for more than one table ?
Yes.
> Let's say I create a pkey_seq sequence.
> Can I use it in table A (pkey default nextval('pkey_seq') PRIMARY KEY) and
> in table B as (pkey default nextval('pkey_seq') PRIMARY KEY) ?
Just like that.
> Is it safe in that each table will have unique values i.e. if I have a
> third table C which is used to link data both from A and B using the pkey
> field, will there be records having the same pkey but from different
> tables?
The sequence-generated numbers will be unique across A and B. But I doubt
that that system is a good design.
--
Peter Eisentraut peter_e(at)gmx(dot)net
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2002-03-11 17:04:36 | Re: One sequence for different tables |
Previous Message | Bruno Wolff III | 2002-03-11 16:56:36 | Re: One sequence for different tables |