Re: inheritance and table

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: inheritance and table
Дата
Msg-id 20060626204555.11812.qmail@web31810.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на inheritance and table  (nik600 <nik600@gmail.com>)
Список pgsql-general
> i don't have understand how works inheritance of tables...
> if table B inherits from table A
> - A and B must share primary keys?

No, currently there is no unique constraint that will force uniqueness across parent/child/sibling
tables.  Just think of them as being nothing more than seperate table that share simlar
data-definitions.

When you select * from parent;  you are essentially preforming a:

select * from parent
union
select * from childa
union
select * from childb ....;

if you want to only see the records in A then select * from only parent;

> - if i isert record in B the record is replaced in A ?
>
> can i avoid this?

This will not happen, you will end up with two records one A and one in B.


> i would like to have this scenario:
>
> table A
>
> table B inheridts from A
> table C inheridts from A
>
> if i insert a record in B it must be insered only in B!
> if i insert a record in C it must be insered only in C!

This is how is it will work.

http://www.postgresql.org/docs/8.1/interactive/ddl-inherit.html
Notice 5.8.1. Caveats

Regards,

Richard Broersma Jr.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: limit over attribute size if index over it exists
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: RAID + PostgreSQL?