Union Vs. Union all

SQL Language Elements, Identifiers, Data Types, Operators, Comments, Query Expressions, Search Conditions, Expressions, Literals and Functions Etc,
Post Reply
AyubHussain
Posts: 138
Joined: Fri Nov 23, 2018 2:48 am

Union Vs. Union all

Post by AyubHussain » Tue Dec 04, 2018 6:09 am

What is difference between Union and Union all Operators?

dsusmitha
Posts: 62
Joined: Fri Nov 23, 2018 2:51 am

Re: Union Vs. Union all

Post by dsusmitha » Tue Dec 04, 2018 6:11 am

Union :

1.Union Set operator is used to fetch the records from 2 different tables which eliminates the duplicate records
2.Syntax:Select col1,col2…from table1;
Union
Select col1,col2…from table2
3.For Performance tuning Union operator is not preferable as it takes time to eliminate duplicate records

Union ALL :

1.Union all Set operator is used to fetch the records from 2 different tables which does not eliminates the duplicate records
2.Syntax:Select col1,col2…from table1;
Union
Select col1,col2…from table2;
3.Union all is preferable operator in Performance tuning.

Post Reply

Return to “SQL Language Elements”