Results 1 to 9 of 9

Thread: UNION vs UNION ALL

  1. #1
    Junior Member
    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
    Expert Member
    Join Date
    Sep 2005
    Answers
    206

    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
    Expert Member
    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
    Junior Member
    Join Date
    Dec 2011
    Answers
    16

    Re: UNION vs UNION ALL

    Thanks Suji n James .. for the answer.


  5. #5
    Junior Member
    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
    Junior Member
    Join Date
    Dec 2011
    Answers
    16

    Re: UNION vs UNION ALL

    Thanks all for your precious shares .....


  7. #7
    Junior Member
    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
    Junior Member
    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


  9. #9
    Junior Member
    Join Date
    Apr 2008
    Answers
    3

    Re: UNION vs UNION ALL

    Union shows the common records without duplicate from the queried tables. Whereas union all shows all the records from the tables.

    Last edited by admin; 08-11-2013 at 09:15 AM.

  10.  Sponsored Ads
    Ad


     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact