select a.empno from emp a where a.empno not in
(select empno from emp1 where job=´SALE´);
倘若利用外部聯(lián)接,改寫命令如下:
以下是代碼片段: select a.empno from emp a ,emp1 b where a.empno=b.empno(+) and b.empno is null and b.job=´SALE´; |
可以發(fā)現(xiàn),運(yùn)行速度明顯提高.
3.刪除表內(nèi)重復(fù)記錄的方法
可以利用這樣的命令來刪除表內(nèi)重復(fù)記錄:
以下是代碼片段: delete from table_name a where rowid< (select max(rowid) from table_name where column1=a.column1 and column2=a.column2 and colum3=a.colum3 and …); |
不過,當(dāng)表比較大(例如50萬條以上)時,這個方法的效率之差令人無法忍受,需要另想辦法(可參看拙文《電信計費(fèi)中長途重復(fù)話單的技術(shù)處理》,《計算機(jī)與通信》,1999-07).