what is the difference between union and union all
Answers were Sorted based on User's Feedback
Answer / soubhagya
Union:
It retrieves only distinct records.
Union all:
This retrieves duplicate records too.
but in performance issue
unioun all is better becoz it doesnot sort, filter the
record so its faster.
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / srinivas
Another difference is that union will sort the result sets
whereas union all will not.
Is This Answer Correct ? | 4 Yes | 1 No |
Answer / vibha kant pandey
Hi friends check it this may help you all.
UNION
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.
UNION ALL
The UNION ALL command is equal to the UNION command, except
that UNION ALL selects all values.
The difference between Union and Union all is that Union all
will not eliminate duplicate rows, instead it just pulls all
rows from all tables fitting your query specifics and
combines them into a table.
A UNION statement effectively does a SELECT DISTINCT on the
results set. If you know that all the records returned are
unique from your union, use UNION ALL instead, it gives
faster results.
Example :-
Table X contain values(a,b,c) and Table Y
contain values(c,d,e)
In Case Of Union we will get Result-a,b,c,d,e
and other hand (Union All ) we will get-a,b,c,c,d,e.
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / leena
union all will combine the outputs of two or more queries.
union will combine the outputs of two or more queries but remove or ignore duplicate value in output.
union all is most faster as compare to union
Is This Answer Correct ? | 1 Yes | 0 No |
What are %type and %rowtype for?
How do you write a subquery?
Why we use joins in sql?
what is self-join? : Sql dba
What are the types of variables use in pl sql?
What are local and global Indexes and where they are useful.
Can we use SQL%ISOPEN in implicit cursors? Does this attribute works properly in Implicit Curosors?
how do you control the max size of a heap table? : Sql dba
what is the difference between binary_integer and pls_integer
Table 1: col1 Timestamp ---------------- 01-mar-2012 11:12:46 Table 2: col2 Timestamp -------------------- 01-mar-2012 11:12:10 01-mar-2012 11:11:23 Write a query to display a row with table2 col2 value less than tabl1 col1 value. Maximum timestamp value previous to table1 col1 value. Display a result as: Col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10
What is view? Can we update view
What is a temp table?