Sequences and inheritance - Mailing list pgsql-general

From Bruce Richardson
Subject Sequences and inheritance
Date
Msg-id 20010731.14183500@usb.cafod
Whole thread Raw
Responses Re: Sequences and inheritance
Re: Sequences and inheritance
List pgsql-general
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?

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?

--

Bruce




pgsql-general by date:

Previous
From: "Dave Cramer"
Date:
Subject: RE: Please Help JDBC Error!!
Next
From: Einar Karttunen
Date:
Subject: Re: Sequences and inheritance