pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Robert.Farrugia@go.com.mt
Cc: pgsql-admin@postgresql.org
Subject: Re: One sequence for different tables
Date: Mon, 11 Mar 2002 10:56:36 -0600
Message-ID: <20020311165636.GA23118@wolff.to> (raw)
In-Reply-To: <20020311142129.6DEB54759B1@postgresql.org>
References: <20020311142129.6DEB54759B1@postgresql.org>

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.



view thread (5+ messages)  latest in thread

Message-ID: <20020311165636.GA23118@wolff.to>
Permalink:  ../20020311165636.GA23118@wolff.to/
Also on:    postgresql.org/message-id/20020311165636.GA23118@wolff.to

 · 

reply

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: bruno@wolff.to, Robert.Farrugia@go.com.mt
  Subject: Re: One sequence for different tables
  In-Reply-To: <20020311165636.GA23118@wolff.to>
  References: <20020311142129.6DEB54759B1@postgresql.org> <20020311165636.GA23118@wolff.to>

* 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