Re: Visibility of data from table inherits function

From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: ourdiaspora <ourdiaspora(at)protonmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Visibility of data from table inherits function
Date: 2022-01-02 15:54:49
Message-ID: CA+bJJbwsUtM-fpcPAVcNuPoyGkqwhoSnFTBY8gSBJ5zOKpBdug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, 2 Jan 2022 at 13:23, ourdiaspora <ourdiaspora(at)protonmail(dot)com> wrote:
> CREATE TABLE exampletable (
> name varchar(200)
> );
...
> CREATE TABLE exampletablechild (dates DATE) INHERITS (exampletable);
...
> Please could someone explain why the data in the table 'exampletable' is not visible from the query using the child table?
> Does not 'INHERIT' function apply to the data of the precedent parent table?

No, it works the other way round, somehow like OO inheritance.

When you query a table you will see its data and all of the tables
that inherit from it.

Take a look at https://www.postgresql.org/docs/14/tutorial-inheritance.html
. Ii is not shown there, but you canot see cities through capitals
because they do not have state, so they do not match the structure,
but you can see capitals through cities.

Inherits does not copy things. LIKE on creation does, but AFAIK it can
copy nearly everything except data.

Francisco Olarte.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message ourdiaspora 2022-01-02 19:41:56 Re: Visibility of data from table inherits function
Previous Message David G. Johnston 2022-01-02 15:50:54 Re: Visibility of data from table inherits function