Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Diff. between UNION and UNION ALL

Re: Diff. between UNION and UNION ALL

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 1997/03/01
Message-ID: <331796dc.3369845@nntp.mediasoft.net>#1/1

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                          

http://govt.us.oracle.com


statements and opinions are mine and do not necessarily reflect the opinions of Oracle Corporation Received on Sat Mar 01 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US