From: | Christian Schröder <cs(at)deriva(dot)de> |
---|---|
To: | Dilyan Berkovski <berkovski(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: inherit table and its data |
Date: | 2008-11-21 12:14:37 |
Message-ID: | 4926A62D.70608@deriva.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Dilyan Berkovski wrote:
> I am using PostgreSQL 8.2, and I am interested in creating a table B that inherits table A, but with all it's data!
>
> create table B {a int} inherits A, just adds the structure of table A, not its data.
>
PostgreSQL's inheritance works the other way around: If table B inherits
table A and you select all records from A you will also get all records
from B (but only the fields that are inherited from A). This is
consistent with the definition of inheritance in object-oriented
programming.
Consider the example from the manual (chapter 5.8): Assume you have a
table with cities and a table with capitals which inherits from the
cities table. If you select from the capitals table, why should you
expect to get all cities, even those that are not capitals?
> Is it possible to do this without the classic way - trigger on table A so each insert/update is done also in B, or it's not possible without triggers.
>
I don't think so.
Regards,
Christian
--
Deriva GmbH Tel.: +49 551 489500-42
Financial IT and Consulting Fax: +49 551 489500-91
Hans-Böckler-Straße 2 http://www.deriva.de
D-37079 Göttingen
Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer
From | Date | Subject | |
---|---|---|---|
Next Message | paulo matadr | 2008-11-21 12:37:02 | converter pgplsql funcion |
Previous Message | Willy-Bas Loos | 2008-11-21 11:46:41 | Re: [pgsql-general] cant find postgres executable after initdb |