Received: from wolff.to (wolff.to [66.92.219.49]) by postgresql.org (Postfix) with SMTP id A62FE4766C8 for ; Mon, 11 Mar 2002 11:54:48 -0500 (EST) Received: (qmail 23130 invoked by uid 500); 11 Mar 2002 16:56:36 -0000 Date: Mon, 11 Mar 2002 10:56:36 -0600 From: Bruno Wolff III To: Robert.Farrugia@go.com.mt Cc: pgsql-admin@postgresql.org Subject: Re: One sequence for different tables Message-ID: <20020311165636.GA23118@wolff.to> Mail-Followup-To: Robert.Farrugia@go.com.mt, pgsql-admin@postgresql.org References: <20020311142129.6DEB54759B1@postgresql.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020311142129.6DEB54759B1@postgresql.org> User-Agent: Mutt/1.3.25i X-Archive-Number: 200203/132 X-Sequence-Number: 3666 On Mon, Mar 11, 2002 at 03:20:35PM +0100, Robert.Farrugia@go.com.mt wrote: > Hi, > > 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) ? > 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? The sequence values will be unique accross tables when doing things this way.