Search Postgresql Archives

Re: inherit table and its data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux