Re: inheritance and table

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: nik600 <nik600(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: inheritance and table
Date: 2006-06-26 20:45:55
Message-ID: 20060626204555.11812.qmail@web31810.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message James 2006-06-26 20:51:24 psql -h host ...
Previous Message Tom Lane 2006-06-26 20:25:10 Re: limit over attribute size if index over it exists