Re: Use of OIDS as primary keys - Mailing list pgsql-general

From Patrick Welche
Subject Re: Use of OIDS as primary keys
Date
Msg-id 20020512114404.F9305@quartz.newn.cam.ac.uk
Whole thread Raw
In response to Use of OIDS as primary keys  (Alan Wayne <alanjwayne@yahoo.com>)
List pgsql-general
On Sat, May 11, 2002 at 11:23:05PM -0700, Alan Wayne wrote:
> Hi!
>
> I'm wondering how I can use the system generated OIDS
> as primary keys. Does postgre automatically fill in
> the system generated oid when a field of type oid is
> created as the primary key? And if so, how do I read
> it back on a record just created so I can use it as a
> secondary key in another table? And lastly, is it even
> a good idea to use the oid as keys at all when I'm
> going to eventually migrate the data from one machine
> to another?

I believe that every row in a table already has a field "oid". You can see
this if you select oid,* from yourtable; If you create another column of
type oid in your table, it's up to you to fill it in (but no need to bother,
column "oid" is already there). I wouldn't use oids as primary keys, but
rather create a column of type "serial".

Cheers,

Patrick

pgsql-general by date:

Previous
From: Peter Dimov
Date:
Subject: Trigger performance
Next
From: Tom Lane
Date:
Subject: Re: Serious environment problem with 7.2 on Solaris