Re: Inheritance

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема Re: Inheritance
Дата
Msg-id 200007300523.e6U5NAA00803@linda.lfix.co.uk
обсуждение исходный текст
Ответ на Inheritance  (Ian Turner <vectro@pipeline.com>)
Ответы Re: Inheritance  (Ian Turner <vectro@pipeline.com>)
Список pgsql-general
Ian Turner wrote:
  >Is there a way to set it up so that tables B and C are both children of
  >table A, but where if you add records to B or C, they will show up in A as
  >well (albiet without the extra fields provided by B and C)?
  >
  >In case that wasn't thouroughly confusing, allow me to try another
  >analogy:
  >
  >CREATE TABLE Entities (num serial PRIMARY KEY);
  >CREATE TABLE Corporations (name char(40));
  >CREATE TABLE Players (name char(40),
  >              corp integer REFERENCES Corporations
  >) INHERITS Entities;
  >
  >Now, if I insert something into players, like so:
  >INSERT INTO Players (name) VALUES ('John');
  >
  >John WILL get a number pulled from the same set as the entity and
  >corporation tables, but John WILL NOT show up in the entities table. Is
  >there any way to get new entries in child tables to show up in the parent
  >table?

`SELECT * FROM Entities*;'

up to and including 7.0.x.

In 7.1, I believe a select on the parent will automatically show the
children and you will need to do something like `SELECT * FROM ONLY Entities'
to exclude descendant tables.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "And Samuel said, Hath the LORD as great delight in
      burnt offerings and sacrifices, as in obeying the
      voice of the LORD? Behold, to obey is better than
      sacrifice, and to hearken than the fat of rams."
                                     I Samuel 15:22



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

Предыдущее
От: Jouni Ahto
Дата:
Сообщение: Re: [PHP-INST] problem compiling php for pgsql
Следующее
От: Ian Turner
Дата:
Сообщение: Re: Inheritance