From: Michael Fuhr <mike@fuhr.org>
To: David Bear <David.Bear@asu.edu>
Cc: pgsql-admin@postgresql.org
Subject: Re: using oids as primary keys and foreign keys
Date: Mon, 8 Nov 2004 16:29:43 -0700
Message-ID: <20041108232943.GA70895@winnie.fuhr.org> (raw)
In-Reply-To: <20041108223626.GA24870@asu.edu>
References: <20041108223626.GA24870@asu.edu>
On Mon, Nov 08, 2004 at 03:36:26PM -0700, David Bear wrote:
> I've looked in the archives searching on oid and 'access' (microsoft)
> to see how others have handled migration from data bases in ms-access
> to postgresql. MS access has an auto-inc field that is used frequently
> as a uniq id. Seems the OID has the same function. Yet, I've seem
> parts of messages that say not to use the OID in that manner, but
> nothing seems 'definitive'.
The PostgreSQL documentation recommends against using OIDs as
primary keys:
http://www.postgresql.org/docs/7.4/static/datatype-oid.html> Can I use an OID as a foreign key in another table?
>
> If not, what is the prefered method for replicating the auto-inc field
> that ms-access users are so fond of... a 'sequence'?
Yes, usually by creating a field of type SERIAL:
http://www.postgresql.org/docs/7.4/static/datatype.html#DATATYPE-SERIAL
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: mike@fuhr.org, David.Bear@asu.edu
Subject: Re: using oids as primary keys and foreign keys
In-Reply-To: <20041108232943.GA70895@winnie.fuhr.org>
References: <20041108223626.GA24870@asu.edu> <20041108232943.GA70895@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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