What is the exact difference b/w IN and EXIST in Oracle..?
Answer Posted / moorthy g
select ename from emp e
where mgr in (select empno from emp whereename = 'KING');
Here's the EXPLAIN PLAN for this query:
OBJECT OPERATION
---------- ----------------------------------------
SELECTSTATEMENT()
NESTEDLOOPS()
EMP TABLEACCESS(FULL)
EMP TABLEACCESS(BY INDEX ROWID)
PK_EMP INDEX(UNIQUESCAN)
This query is virtually equivalent to this:
select e1.ename from emp e1,(select empno from empwhere
ename = 'KING') e2
where e1.mgr = e2.empno;
You can write the same query using EXISTS bymoving the outer
query column to a subquery condition, likethis:
select ename from emp e
where exists (select 0 from emp wheree.mgr = empno and
ename = 'KING');
When you write EXISTS in a where clause, you'retelling the
optimizer that you want the outer query to be runfirst,
using each value to fetch a value from the inner
query(think: EXISTS = outside to inside).
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is exclusive and normal mode for repository services?
Target increases every day even though no new record was inserted
What is the session task and command task?
What are the features of complex mapping?
What is the main purpose of Unconnected lookup other than updating slowly changing dimensions? or In which case u use Unconnected lookup?
Can we get 1st record through Informatica(without sequence number).
What are some examples of informatica etl programs?
Under what condition selecting sorted input in aggregator may fail the session?
Briefly describe lookup transformation?
What are the new features of Power Center 5.0?
What is native users?
What is the scenario which compels informatica server to reject files?
Can some one explain me about Telecommunications(wireless) project in Informatica? Thanks in advance
Explain what is informatica metadata and where is it stored?
Can any one give me a real time example for FACT TABLE & DIMENSIONAL TABLE?