Q: inheritance

Поиск
Список
Период
Сортировка
От Rüdiger Sörensen
Тема Q: inheritance
Дата
Msg-id 4938080C.2010905@mpch-mainz.mpg.de
обсуждение исходный текст
Ответы Re: Q: inheritance  (Richard Huxton <dev@archonet.com>)
Re: Q: inheritance  ("Richard Broersma" <richard.broersma@gmail.com>)
Список pgsql-general
hi,

I think I misunderstand the concept of inheritance. I was under the
impression that inheriting from an existing table inherits all of the
parent's columns.

But:

create table t1 (id serial primary key);
create table t2 (num int) inherits (t1);
create table t3 (t1 int references t1(id));

insert into t2 (id, num) values (1,1);
-- so far , so good
-- the next one fails:
insert into t3 (t1) values (1);

fails with an error (translated from german):

insert or update in table "t3" violates foreign key constraint "t3_t1_fkey"
DETAIL: key(t1)=(1) is not present in table "t1"

but:

select * from t2;
 id | num
----+-----
  1 |   1

can anyone explain this behaviour? My database setup relies on inherited
tables that share a primary key.

cheers, Rüdiger.





В списке pgsql-general по дате отправления:

Предыдущее
От: "Dave Page"
Дата:
Сообщение: Re: Job scheduling in Postgre
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Q: inheritance