SQL Language (MOSC)

MOSC Banner

Can you please help advise about not exists and not in?

edited Oct 1, 2013 10:04PM in SQL Language (MOSC) 7 commentsAnswered
Hi expert,
I would like to know how difference between "NOT EXISTS" and "NOT IN". I have to fix some script from old DBA had been setup for monitoring db. 

===Below is machine name connect to testdb

SQL> select distinct userhost from dba_audit_trail;

USERHOST
--------------------------------------------------------------------------------
WORKGROUP\NUMNIMJUN-PC
racnode2
racnode1


===Below is list of allowed server keep in b table.

SQL> select * from b;

MACHINE
--------------------------------------------------------------------------------
WORKGROUP\NUMNIMJUN-PC
racnode2


===Assume we not allow racnode1 to connect db.

from the old script they used like this:

SQL> select distinct userhost from dba_audit_trail
  2  where not exists (select machine from b);

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center