Re: Sequences and inheritance

From: Einar Karttunen <ekarttun(at)cs(dot)Helsinki(dot)FI>
To: Bruce Richardson <brichardson(at)lineone(dot)net>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Sequences and inheritance
Date: 2001-07-31 13:31:42
Message-ID: Pine.LNX.4.33.0107311630450.20135-100000@melkinpaasi.cs.Helsinki.FI
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 31 Jul 2001, Bruce Richardson wrote:

> If I have a set of tables and I set their primary keys all to the same
> sequence, as in
>
> create sequence common_seq;
>
> create table alpha (
> ID integer primary key default nextval('common_seq),
> other_field text
> );
>
> create table beta (
> ID integer primary key default nextval('common_seq),
> other_field real
> );
> create table gamma (
> ID integer primary key default nextval('common_seq),
> other_field oid
> );
>
> Would this guarantee that each value of ID in any row of any of the
> tables would be unique amongst all of them?
yes

> Would I get the same effect by creating a table like this:
>
> create table common (
> ID serial primary key
> );
>
> and then having alpha, beta and gamma inherit from it?
>
no. Primary key constraints are currently not inherited. See the todo-list
for more details.

- Einar Karttunen

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bernie Holmes 2001-07-31 13:45:06 Getting Primary * Foreign Key Information?
Previous Message Bernie Holmes 2001-07-31 13:28:37 Getting Primary & Foreign Key Information?