GeekInterview.com
Results 1 to 8 of 8

UNION vs UNION ALL

This is a discussion on UNION vs UNION ALL within the Databases forums, part of the category; What are the major difference between 'UNION' and 'UNION ALL' in ORACLE ?...

  1. #1
    Pradeep_Oracle is offline Junior Member Array
    Join Date
    Dec 2011
    Answers
    16

    Post UNION vs UNION ALL

    What are the major difference between 'UNION' and 'UNION ALL' in ORACLE ?


  2. #2
    suji is offline Expert Member Array
    Join Date
    Sep 2005
    Answers
    191

    Re: UNION vs UNION ALL

    The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type. With UNION, only distinct values are selected.

    The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values. This will not remove duplicate values. Just gets all the records matches your criteria in where clause.


  3. #3
    jamesravid is offline Expert Member Array
    Join Date
    Jun 2006
    Answers
    410

    Re: UNION vs UNION ALL

    Just to add Suji's answer, UNION ALL has better performance as it does not have to return DISTINCT set of records.


  4. #4
    Pradeep_Oracle is offline Junior Member Array
    Join Date
    Dec 2011
    Answers
    16

    Re: UNION vs UNION ALL

    Thanks Suji n James .. for the answer.


  5. #5
    amycompton is offline Junior Member Array
    Join Date
    May 2012
    Answers
    18

    Re: UNION vs UNION ALL

    The main difference is that UNION will eliminate any duplicate rows returned by the various select statements being unioned whereas UNION ALL will not. It will return all records even duplicates.


  6. #6
    Pradeep_Oracle is offline Junior Member Array
    Join Date
    Dec 2011
    Answers
    16

    Re: UNION vs UNION ALL

    Thanks all for your precious shares .....


  7. #7
    rayavarapu is offline Junior Member Array
    Join Date
    Jan 2013
    Answers
    9

    Re: UNION vs UNION ALL

    union: it will not displayed duplicate values(displays distinct values)
    unionall: it will display all values...


  8. #8
    nehrumosuru is offline Junior Member Array
    Join Date
    Oct 2008
    Answers
    28

    Re: UNION vs UNION ALL

    Union - It will show only distinct rows

    Union all - I will show all rows with duplicate rows


    •    Sponsored Ads