Re: Inherit a primary key?
От | missive@frontiernet.net (Lee Harr) |
---|---|
Тема | Re: Inherit a primary key? |
Дата | |
Msg-id | 9jnja1$3hl8$3@node21.cwnet.roc.gblx.net обсуждение исходный текст |
Список | pgsql-general |
On Thu, 26 Jul 2001 08:04:58 +1000, Paul Gear <paulgear@bigfoot.com> wrote: > Hi All, > > Can anyone tell me whether i am doing something wrong or if this is > simply not supported at the moment? > > What i would like to do is have a generic object as the root of my > table inheritance hierarchy, thus: > > create table object ( > id serial primary key, > label text not null, > notes text > ); > > And then inherit my actual entities from object, like this: > > create table bar ( > name text, > version text > ) inherits ( object ); > > Then i would like to refer to the inherited table, like this: > > create table foo ( > name text, > barid integer references bar, > ); > > However, when i try to create foo, i get this: > > NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN > KEY check(s) > ERROR: PRIMARY KEY for referenced table "bar" not found > > What seems to have happened is that all the fields of object were > inherited by bar, but not the primary key. So there is no primary key > for foo to reference, and the references clause fails. > > What is the problem? Is inheritance of primary keys not supported, or > do i need to do something else? > > I'm using version 7.0.3 on Red Hat 7.1. > From the ToDo list: Allow inherited tables to inerit index, UNIQUE contraint, and primary key, foreign key. There is also a page in ToDo detail about inheritance. This one bit me before too. It seems like it would be a Good Thing. Just waiting for someone to take on the challenge :)
В списке pgsql-general по дате отправления: