pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
general question on OIDs
3+ messages / 2 participants
[nested] [flat]

* general question on OIDs
@ 2001-05-05 17:21 Oliver Vecernik <vecernik@aon.at>
  2001-05-06 04:36 ` Re: general question on OIDs Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Oliver Vecernik @ 2001-05-05 17:21 UTC (permalink / raw)
  To: pgsql-admin

Hi,

Using of OIDs as foreign keys is recommended in the docs. It is a unique
number for every object of the PostgreSQL server. I can dump OIDs with
-o option.

But what happens if I have to upgrade my server? For example for the new
7.1 release an initdb is required. OIDs start from 16384 or something.
After importing my old databases can I expect that OIDs are not unique
any more? Or is there any other handling to prevent this?

Regards,
Oliver



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: general question on OIDs
  2001-05-05 17:21 general question on OIDs Oliver Vecernik <vecernik@aon.at>
@ 2001-05-06 04:36 ` Tom Lane <tgl@sss.pgh.pa.us>
  2001-05-06 15:51   ` Re: general question on OIDs Oliver Vecernik <vecernik@aon.at>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2001-05-06 04:36 UTC (permalink / raw)
  To: Oliver Vecernik <vecernik@aon.at>; +Cc: pgsql-admin

Oliver Vecernik <vecernik@aon.at> writes:
> Using of OIDs as foreign keys is recommended in the docs.

Er ... where?  It shouldn't be.

> But what happens if I have to upgrade my server? For example for the new
> 7.1 release an initdb is required. OIDs start from 16384 or something.
> After importing my old databases can I expect that OIDs are not unique
> any more? Or is there any other handling to prevent this?

This is why it shouldn't be.  Reloading a pg_dump-with-OIDs will
probably yield a conflict-free database, but it's not certain;
and it is certain that you'll waste lots of OIDs that way.  Much
better to use serial columns for foreign keys.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: general question on OIDs
  2001-05-05 17:21 general question on OIDs Oliver Vecernik <vecernik@aon.at>
  2001-05-06 04:36 ` Re: general question on OIDs Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-05-06 15:51   ` Oliver Vecernik <vecernik@aon.at>
  0 siblings, 0 replies; 3+ messages in thread

From: Oliver Vecernik @ 2001-05-06 15:51 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-admin

Tom Lane wrote:
> 
> Oliver Vecernik <vecernik@aon.at> writes:
> > Using of OIDs as foreign keys is recommended in the docs.
> 
> Er ... where?  It shouldn't be.

Sorry, it was not in the official docs, but in Bruce's book in the
chapter about OIDs:

| Object identification numbers can be used as primary and foreign key 
values in  | joins. Since every row has a unique object ID, a separate
column is not needed to | hold the row's unique number. 
| 
| For example, in Chapter  we used a column called customer.customer_id.
This
| column held the customer number and uniquely identified each row.
Alternatively, | we could have used the row's object identification
number as the unique number
| for each row, eliminating the need to create the | | column
customer.customer_id. | In that case, customer.oid would be the unique
customer number. 

> 
> [...]
>
> This is why it shouldn't be.  Reloading a pg_dump-with-OIDs will
> probably yield a conflict-free database, but it's not certain;
> and it is certain that you'll waste lots of OIDs that way.  Much
> better to use serial columns for foreign keys.
> 
>                         regards, tom lane

Everthing is clear now. I won't use OIDs for foreign keys.

Regards,
Oliver



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-05-06 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-05-05 17:21 general question on OIDs Oliver Vecernik <vecernik@aon.at>
2001-05-06 04:36 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-05-06 15:51   ` Oliver Vecernik <vecernik@aon.at>

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