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


Please Help Members By Posting Answers For Below Questions

Why do we use stored procedures in sql server?

589


What is molap and its advantage? : sql server analysis services, ssas

621


According to you what goes into making the best database administrator? : sql server database administration

627


Different types of keys in SQL?

727


What are the advantages of passing name-value pairs as parameters?

741






What are different types of database indexes?

613


What are different types of collation sensitivity?

622


What language is sql server written in?

615


Define tool Manage Statistics in SQL Server 2000 query ?

609


What is set nocount on?

585


how to do partition in sqlserver

2052


What is the process of normalising?

689


How to update multiple rows with one update statement in ms sql server?

739


What is the chart in report?

113


What is nonclustered index on computed columns?

646