X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5D8023A411D for ; Mon, 8 Nov 2004 23:29:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80269-03 for ; Mon, 8 Nov 2004 23:29:47 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 0DD863A40D7 for ; Mon, 8 Nov 2004 23:29:48 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id iA8NThTY004693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 8 Nov 2004 16:29:46 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id iA8NTh6N070923; Mon, 8 Nov 2004 16:29:43 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id iA8NThtk070922; Mon, 8 Nov 2004 16:29:43 -0700 (MST) (envelope-from mfuhr) Date: Mon, 8 Nov 2004 16:29:43 -0700 From: Michael Fuhr To: David Bear Cc: pgsql-admin@postgresql.org Subject: Re: using oids as primary keys and foreign keys Message-ID: <20041108232943.GA70895@winnie.fuhr.org> References: <20041108223626.GA24870@asu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041108223626.GA24870@asu.edu> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/68 X-Sequence-Number: 15453 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/