From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | "trescher40(at)gmx(dot)de" <trescher40(at)gmx(dot)de>, "pgsql-docs(at)lists(dot)postgresql(dot)org" <pgsql-docs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: UNION does not append |
Date: | 2025-10-08 11:29:06 |
Message-ID: | CAKFQuwYHOB1Wp7ZxbHveNrm2PiczNFjy5dPQoJtxT2zJyiU6UA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs |
On Tuesday, October 7, 2025, PG Doc comments form <noreply(at)postgresql(dot)org>
wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/18/queries-union.html
> Description:
>
> I'm very confused about this statement in the documentation of UNION:
> "UNION
> effectively appends the result of query2 to the result of query1".
> Because, if I append one item to a list, it is still the same list. But in
> the case of UNION, it's ""copied"" into a new anonymous derived-table.
> Alias
> don't work anymore, which I would expect if I just append some rows. Or is
> it like "effectively" means that this statement is not to be taken
> literally? In that case I would really appreciate a more detailed
> description, that after the UNION with tables a new anonymous derived-table
> is returned and the original first table can't be accessed anymore. Thank
> you for taking your time to read this even if you disagree.
>
Yes, if you place a set-operation using query into a subquery context the
subquery has to be given its own name: and the individual from clause
relations of the contained query are not exposed. This is just how
subqueries work.
If you don’t place it in a subquery the rows are just sent to the client.
In both cases the word append simply means “using the column structure of
the first component query”. Though Imsuppose that is strictly “column
names” since types can be changed to a more encompassing one if needed.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Oleg | 2025-10-10 06:38:14 | Re: Documentation improvement patch |
Previous Message | Laurenz Albe | 2025-10-08 08:33:31 | Re: UNION does not append |