Re: [GENERAL] inherit table and its data

2008-11-21 Thread Christian Schröder

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



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] inherit table and its data

2008-11-17 Thread Dilyan Berkovski
hi All,
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. 

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.

thanks, Dilyan



  

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general