pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feed3.6 Inheritance Documentation
2+ messages / 2 participants
[nested] [flat]
* 3.6 Inheritance Documentation
@ 2023-08-02 19:54 PG Doc comments form <noreply@postgresql.org>
2023-08-08 09:36 ` Re: 3.6 Inheritance Documentation Peter Eisentraut <peter@eisentraut.org>
0 siblings, 1 reply; 2+ messages in thread
From: PG Doc comments form @ 2023-08-02 19:54 UTC (permalink / raw)
To: pgsql-docs@lists.postgresql.org; +Cc: watermelonmania79@gmail.com
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/15/tutorial-inheritance.html
Description:
The documentation for inheritance in PostgreSQL is not entirely accurate in
the given example.
In the provided example, the cities table and the capitals table have a
parent-child relationship through inheritance. However, querying the cities
table directly (e.g., SELECT name, elevation FROM cities WHERE elevation >
500;) will not automatically include data from the child table, capitals.
Inheritance in PostgreSQL does not implicitly combine data from parent and
child tables in a single query.
To include data from both the parent and child tables, a UNION or other join
operations must be used, as I previously explained.
The documentation should be corrected to clarify that inheritance does not
automatically combine data from parent and child tables when querying the
parent table directly. It might be updated to provide a better example
demonstrating the use of UNION or JOIN operations to retrieve data from both
parent and child tables.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: 3.6 Inheritance Documentation
2023-08-02 19:54 3.6 Inheritance Documentation PG Doc comments form <noreply@postgresql.org>
@ 2023-08-08 09:36 ` Peter Eisentraut <peter@eisentraut.org>
0 siblings, 0 replies; 2+ messages in thread
From: Peter Eisentraut @ 2023-08-08 09:36 UTC (permalink / raw)
To: watermelonmania79@gmail.com; pgsql-docs@lists.postgresql.org
On 02.08.23 21:54, PG Doc comments form wrote:
> In the provided example, the cities table and the capitals table have a
> parent-child relationship through inheritance. However, querying the cities
> table directly (e.g., SELECT name, elevation FROM cities WHERE elevation >
> 500;) will not automatically include data from the child table, capitals.
> Inheritance in PostgreSQL does not implicitly combine data from parent and
> child tables in a single query.
This observation is patently incorrect:
CREATE TABLE cities (
name text,
population real,
elevation int -- (in ft)
);
CREATE TABLE capitals (
state char(2) UNIQUE NOT NULL
) INHERITS (cities);
INSERT INTO cities (name) VALUES ('Ithaca');
INSERT INTO capitals (name, state) VALUES ('Albany', 'NY');
SELECT * FROM cities;
name | population | elevation
--------+------------+-----------
Ithaca | |
Albany | |
(2 rows)
SELECT * FROM capitals;
name | population | elevation | state
--------+------------+-----------+-------
Albany | | | NY
(1 row)
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2023-08-08 09:36 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-08-02 19:54 3.6 Inheritance Documentation PG Doc comments form <noreply@postgresql.org>
2023-08-08 09:36 ` Peter Eisentraut <peter@eisentraut.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox