Re: inheritance and table

From: nik600 <nik600(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: inheritance and table
Date: 2006-06-27 06:31:08
Message-ID: 9469c3170606262331u3b96a140q6a323eea4bc33559@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

ok i have understand

many thanks to all!

On 6/27/06, Erik Jones <erik(at)myemma(dot)com> wrote:
> nik600 wrote:
> > hi
> >
> > i don't have understand how works inheritance of tables...
> >
> > if table B inherits from table A
> >
> > - A and B must share primary keys?
> >
> > - if i isert record in B the record is replaced in A ?
> >
> > can i avoid this?
> >
> > 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!
> >
> > is it possible?
> >
> > thanks
> Do you mean like this? (Notice the use of LIKE instead of INHERITS):
>
> CREATE TABLE table_1 (
> a int,
> b int
> )
>
> CREATE TABLE table_2 (
> LIKE table_1
> )
>
> (**Note: CREATE TABLE with INHERITS uses different syntax!**)
>
> INSERT INTO table_1 (a, b) VALUES (1, 2);
> INSERT INTO table_2 (a, b,) VALUES (3, 4);
>
> Now,
>
> SELECT * FROM table_1;
>
> yeilds,
>
> _a | b_
> 1 | 2
>
> and not,
>
> _a | b
> _1 | 2
> 3 | 4
>
> as it would've if you'd used INHERITS instead of LIKE.
>
> --
> erik jones <erik(at)myemma(dot)com>
> software development
> emma(r)
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Franz.Rasper 2006-06-27 07:00:24 Re: RAID + PostgreSQL?
Previous Message chent 2006-06-27 05:35:45 About libpq