Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 48044476235 for ; Mon, 11 Mar 2002 12:04:34 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 2E928D605; Mon, 11 Mar 2002 09:04:36 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 1FF455BFD; Mon, 11 Mar 2002 09:04:36 -0800 (PST) Date: Mon, 11 Mar 2002 09:04:36 -0800 (PST) From: Stephan Szabo To: Cc: Subject: Re: One sequence for different tables In-Reply-To: <20020311142129.6DEB54759B1@postgresql.org> Message-ID: <20020311090350.B45259-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200203/134 X-Sequence-Number: 3668 On Mon, 11 Mar 2002 Robert.Farrugia@go.com.mt wrote: > Is it possible to create one sequence to be used for more than one table ? > Let's say I create a pkey_seq sequence. > Can I use it in table A (pkey default nextval('pkey_seq') PRIMARY KEY) and > in table B as (pkey default nextval('pkey_seq') PRIMARY KEY) ? Yes. > Is it safe in that each table will have unique values i.e. if I have a > third table C which is used to link data both from A and B using the pkey > field, will there be records having the same pkey but from different > tables? As long as you never insert an explicit value into the column and don't have to roll over the sequence, you should be safe.