What are the major difference between 'UNION' and 'UNION ALL' in ORACLE ?
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 ?...
What are the major difference between 'UNION' and 'UNION ALL' in ORACLE ?
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.
Just to add Suji's answer, UNION ALL has better performance as it does not have to return DISTINCT set of records.
Thanks Suji n James .. for the answer.
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.
Thanks all for your precious shares .....
union: it will not displayed duplicate values(displays distinct values)
unionall: it will display all values...
Union - It will show only distinct rows
Union all - I will show all rows with duplicate rows