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
What is t-sql script to take database offline – take database online.
What are different types of roles provided by ssrs?
How to encrypt data between dialogs?
What is self contained sub query?
What is bookmark link in ssrs?
What is indexing in sql server with example?
what is dbcc? : Sql server database administration
Tell me what are cursors and when they are useful?
How to reaname table name without using sp_Rename in sql server..?
Explain filtered indexes?
write an SQL query to list the employees who joined in the month of January?
ow to bring suspect mode datbase online from scratch
What are the fixed server level roles? : sql server security
Recommend an approach to ensuring that all changes in the remote databases synchronize with the SQL Azure database?
what is a self join? Explain it with an example? : Sql server database administration