Обсуждение: Use of OIDS as primary keys

Поиск
Список
Период
Сортировка

Use of OIDS as primary keys

От
Alan Wayne
Дата:
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?

Any help would be appreciated,
AJW





__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

Re: Use of OIDS as primary keys

От
Patrick Welche
Дата:
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