Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Diff. between UNION and UNION ALL
The union of "a" and "b" is the same as:
A concat (B-A)
The union all of "a" and "b" is the same as:
A concath B
The 'union' will retrieve all of the rows in the first query in the statement PLUS all of the rows in the second query that weren't in the first PLUS all of the rows in the third query that weren't in the first 2 and so on....
A 'union all' will simply glue together the end results of all the queries involved.
In general a union involves lots of sorting and merging and a union all is faster but a union and union all may return different results (eg: a union all is not a faster union but may be used in many places where you know the second query will not return any rows selected in the first one)...
On Fri, 28 Feb 1997 14:07:15 -0500, Naren Chintala <naren_at_mink.att.com> wrote:
>Hi,
>
>What's the difference between UNION and UNION ALL (in a SELECT
>statement). I don't find any info on this in the Oracle manuals. Would
>some explain this with a simple example.
>
>TIA
>
>Naren
Thomas Kyte
Oracle Government
tkyte_at_us.oracle.com
![]() |
![]() |