Re: inherit table and its data

Поиск
Список
Период
Сортировка
От Christian Schröder
Тема Re: inherit table and its data
Дата
Msg-id 4926A62D.70608@deriva.de
обсуждение исходный текст
Ответ на inherit table and its data  (Dilyan Berkovski <berkovski@yahoo.com>)
Список 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'snot 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



В списке pgsql-general по дате отправления:

Предыдущее
От: paulo matadr
Дата:
Сообщение: converter pgplsql funcion
Следующее
От: "Ciprian Dorin Craciun"
Дата:
Сообщение: Using Postgres to store high volume streams of sensor readings