pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedreferencing oid impozsible ?
3+ messages / 3 participants
[nested] [flat]
* referencing oid impozsible ?
@ 2001-09-11 14:58 patrick.jacquot@anpe.fr
0 siblings, 2 replies; 3+ messages in thread
From: patrick.jacquot@anpe.fr @ 2001-09-11 14:58 UTC (permalink / raw)
To: pgsql-sql
hello all
I tried recently (pgsql 7.1.2) to establish the oid of one table as foreign key
in another.
To no avail : there was no uniqueness constraint on that column
Naturally, it seems impossible to add a uniqueness constraint to such a system
column.
As far as i know, the oid is by nature unique, excepting for the case of
wrapping of their sequence.
Is there any workaround ?
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: referencing oid impozsible ?
@ 2001-09-11 16:58 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: patrick.jacquot@anpe.fr
1 sibling, 0 replies; 3+ messages in thread
From: Stephan Szabo @ 2001-09-11 16:58 UTC (permalink / raw)
To: patrick.jacquot@anpe.fr; +Cc: pgsql-sql
On Tue, 11 Sep 2001 patrick.jacquot@anpe.fr wrote:
> hello all
> I tried recently (pgsql 7.1.2) to establish the oid of one table as foreign key
> in another.
> To no avail : there was no uniqueness constraint on that column
> Naturally, it seems impossible to add a uniqueness constraint to such a system
> column.
> As far as i know, the oid is by nature unique, excepting for the case of
> wrapping of their sequence.
> Is there any workaround ?
You could add a unique index on oid (which would basically be the unique
constraint), but IIRC it still won't work on the system attribute.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: referencing oid impozsible ?
@ 2001-09-11 17:29 Josh Berkus <josh@agliodbs.com>
parent: patrick.jacquot@anpe.fr
1 sibling, 0 replies; 3+ messages in thread
From: Josh Berkus @ 2001-09-11 17:29 UTC (permalink / raw)
To: pgsql-sql
Patrick,
> I tried recently (pgsql 7.1.2) to establish the oid of one table as
> foreign key
> in another.
> To no avail : there was no uniqueness constraint on that column
> Naturally, it seems impossible to add a uniqueness constraint to such
> a system
> column.
> As far as i know, the oid is by nature unique, excepting for the case
> of
> wrapping of their sequence.
> Is there any workaround ?
Yes. Don't use the OID as your key.
While it would be entirely possible for you add a unique constraint to
the OID column, you do not want to use it as your key for a number of
reasons previously discussed on this list (OID wraparound, problems with
backup and restore, etc.).
Instead, re-create the table with a new ID column of type SERIAL with a
PRIMARY KEY constraint. This will automatically create an
auto-incrementing sequence of unique values perfect for attaching
foriegn keys.
-Josh
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2001-09-11 17:29 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-09-11 14:58 referencing oid impozsible ? patrick.jacquot@anpe.fr
2001-09-11 16:58 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2001-09-11 17:29 ` Josh Berkus <josh@agliodbs.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox