Difference between Union & Union ALL

  • Hi,

    Here is the difference between UNION and UNION ALL.

    UNION:

    1) Exclude duplicate values

    2) Will create work table to sort out the data

    UNION ALL:

    1) Doesn't exclude duplicate values

    2) Will not create work table

    I would appreciate if any expert add some more points.

    karthik

  • I'm not necessarily sure about the work table being there all the time or not. Certainly UNION ALL performs better than UNION because it doesn't need to do as much work. Many people use the UNION operator when they really mean UNION ALL as they know there won't be duplicates in the two sets but still get the results they want anyway with just the UNION operator.

    Why the question? Is this for some sort of exam or are you trying to win a debate at work? 😀

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply