0% found this document useful (0 votes)
7 views1 page

PLSQL NOTES Differences

The document compares the IN and EXISTS operators in SQL. IN can be used with both values and subqueries, while EXISTS can only be used with subqueries. IN is faster for small subquery results, while EXISTS is faster for large subquery results. The inner query of IN is executed once to provide a list of values to the outer query. For EXISTS, the inner query is executed separately for each row of the outer query.

Uploaded by

nagkkkkk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

PLSQL NOTES Differences

The document compares the IN and EXISTS operators in SQL. IN can be used with both values and subqueries, while EXISTS can only be used with subqueries. IN is faster for small subquery results, while EXISTS is faster for large subquery results. The inner query of IN is executed once to provide a list of values to the outer query. For EXISTS, the inner query is executed separately for each row of the outer query.

Uploaded by

nagkkkkk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

IN :

1.IN' can be used on sub-queries as well as with


values.
Egs:
With values:
SELECT *
FROM test_emp
WHERE deptno in ( 10,20,30);
With sub-query:
SELECT *
FROM test_emp
WHERE deptno in ( select deptno
from test_emp
where deptno=10 or deptno=20 or deptno=30);

is faster than EXISTS, when the sub-query


results is very small.

EXISTS:

3.The inner query is executed first and the list of values


obtained as its result is used by the outer query.The
inner query is executed for only once.

queries.

2.IN

1.Whereas 'EXISTS' can only be used on subSELECT *


FROM test_emp
WHERE exists ( select deptno
from test_emp
where deptno=10 or deptno=20 or deptno=30);

is much faster than IN, when the subquery results is very large.
2.EXISTS

3.The first row from the outer query is selected ,then the
inner query is executed and , the outer query output
uses this result for checking.This process of inner query
execution repeats as many no.of times as there are
outer query rows. That is, if there are ten rows that can
result from outer query, the inner query is executed that
many no.of times.

You might also like