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),運行速度明顯提高.
3.刪除表內重復記錄的方法
可以利用這樣的命令來刪除表內重復記錄:
以下是代碼片段: 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 …); |
不過,當表比較大(例如50萬條以上)時,這個方法的效率之差令人無法忍受,需要另想辦法(可參看拙文《電信計費中長途重復話單的技術處理》,《計算機與通信》,1999-07).