like this:
scott@ORA920.US.ORACLE.COM> create or replace directory data_dir as '/tmp/'
2 /
Directory created.
scott@ORA920.US.ORACLE.COM>
scott@ORA920.US.ORACLE.COM> create table external_table
2 (EMPNO NUMBER(4) ,
3 ENAME VARCHAR2(10),
4 JOB VARCHAR2(9),
5 MGR NUMBER(4),
6 HIREDATE DATE,
7 SAL NUMBER(7, 2),
8 COMM NUMBER(7, 2),
9 DEPTNO NUMBER(2)
10 )
11 ORGANIZATION EXTERNAL
12 ( type oracle_loader
13 default directory data_dir
14 access parameters
15 ( fields terminated by ',' )
16 location ('emp.dat')
17 )
18 /
Table created.
scott@ORA920.US.ORACLE.COM>
scott@ORA920.US.ORACLE.COM> host flat scott/tiger emp > /tmp/emp.dat
scott@ORA920.US.ORACLE.COM>
scott@ORA920.US.ORACLE.COM> set autotrace on
scott@ORA920.US.ORACLE.COM> delete from emp
2 where empno not in ( select /*+ HASH_AJ */ empno from external_table where empno is not null )
3 /
0 rows deleted.
Execution Plan
----------------------------------------------------------
0 DELETE STATEMENT Optimizer=CHOOSE (Cost=14 Card=1 Bytes=26)
1 0 DELETE OF 'EMP'
2 1 HASH JOIN (ANTI) (Cost=14 Card=1 Bytes=26)
3 2 TABLE ACCESS (FULL) OF 'EMP' (Cost=2 Card=82 Bytes=1066)
4 2 EXTERNAL TABLE ACCESS (FULL) OF 'EXTERNAL_TABLE' (Cost=11 Card=408 Bytes=5304)
You want the hash anti join to avoid full scanning the external table once for each row in emp and since there won't be stats on it, we can help the SQL along with the hint in this case....
see also
</code>
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:5081797376327 <code>
for "what is this hash anti join thing"