What is the difference between in and exists.
Ex: select * from emp where empno in(....) and
select * from emp where empno exists(....)
What is the difference between a Join and Union and Union
and UnionAll.
Answer Posted / nandkumar karlekar
Answer:-
1. Union is heavy as compare to Union All
2. result of Union Query is Set where as result of
Union ALL is not a Set it’s only concatenation of two
results
3. Suppose table1 and table2 have T1 ,T2 records
respectively then the number of comparison require to
produce result is as follows
Union All requires O (1) time complexity
Union Requires O ((T1*(T1+1)/2) + (T2*(T2+1)/2) + (T1 *T2))
Example for UNION: - Table1 has 10 records
Table2 has 20 records
Suppose: table1 and table2 has all record distinct.
Total comparisons require = 465 comparisons
Example for UNION ALL: -
Table1 has 10 records
Table2 has 20 records
Suppose: table1 and table2 has all record distinct or not,
no problem.
Total comparisons require = Constant or may be 0
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How to disable stored procedure sql server?
What type of Index will get created after executing the above statement?
What are the differences between union, intersect, and minus operators?
How can sql injection be stopped? : sql server security
What are page splits? : SQL Server Architecture
What are the disadvantages of using the stored procedures?
How do I install sql server?
What is order of B+tree?
What are user defined functions in ms sql server?
What are the purpose of Normalisation?
What is lookup override?
What is the purpose of data source?
How to access the deleted record of an event?
Define self join in sql server joins?
What is the difference between ddl,dml and dcl commands?