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 defragment indexes with alter index ... Reorganize?
What is onf in normalization form?
What is the purpose of indexing?
What happens if you add a new index to large table?
Which tcp/ip port does sql server run on? How can it be changed?
How to loop through the result set with @@fetch_status?
What is the difference between composite index and covering index?
is there a column to which a default can't be bound? : Sql server database administration
Is sql server difficult to learn?
What are binary string data types in ms sql server?
Do you know clustered and non-clustered index?
What are character string data types in ms sql server?
explain databases and sql server databases architecture? : Sql server database administration
What is the difference between ddl,dml and dcl commands?
What is similarity and difference between truncate and delete in sql?