posts - 25, comments - 69, trackbacks - 0, articles - 2
          select * from a,b where a.id=b.id(+);
          select * from a left join b on a.id=b.id;

          很多資料說上面兩個語句的效果是一樣的,實際上今天經過測試發現兩者的執行計劃大不相同(查詢結果是一樣的);
          至于為什么會這樣,暫時沒有深究,手頭的一個例子表明按照第一種寫法的效率會高,或許其他的例子結果不一樣,等有時間的時候再測試一下吧.

          Feedback

          # re: oracle 的left join和(+)真的可以起到一樣的效果嗎?  回復  更多評論   

          2007-12-14 10:11 by hao ren
          是的,我也發現了這個問題。
          因為速度的原因,差點搞死我!
          不得已又換成了+號,
          速度居然有兩倍的差距!!
          要是你有什么好的資料或結果的話,
          請告訴我一聲,謝謝。
          wang20yin@126.com

          # re: oracle 的left join和(+)真的可以起到一樣的效果嗎?  回復  更多評論   

          2008-09-16 11:59 by Noodle
          學習,呵呵

          # re: oracle 的left join和(+)真的可以起到一樣的效果嗎?[未登錄]  回復  更多評論   

          2008-10-06 14:44 by null
          把不同的執行計劃貼出來看看啊。

          # re: oracle 的left join和(+)真的可以起到一樣的效果嗎?[未登錄]  回復  更多評論   

          2009-01-19 12:17 by aa
          select * from a,b where a.id=b.id(+) and a.flg = '0';
          select * from a left join b on a.id=b.id and a.flg = '0';

          條件追加:
          -〉and a.flg = '0'

          你看一下區別吧!

          處理方法:
          select * from a left join b on a.id=b.id and a.flg = '0';
          同下!
          select * from a ,b where a.id=b.id and (a.flg = '0' or a.flg is null);


          # re: oracle 的left join和(+)真的可以起到一樣的效果嗎?  回復  更多評論   

          2010-04-01 18:02 by feiyvefanli
          這個是版本問題 好像9i以后 才增加的left join 以前都是使用(+)
          后續版本向下兼容 所以9i之后 這兩者是通用的 但建議使用left jion增加可讀性

          # re: oracle 的left join和(+)真的可以起到一樣的效果嗎?[未登錄]  回復  更多評論   

          2011-05-12 09:58 by AA
          @aa

          select * from a,b where a.id=b.id(+) and a.flg = '0';
          select * from a left join b on a.id=b.id and a.flg = '0';
          這兩個不對等,
          把第一個修改一下
          select * from a,b where a.id=b.id(+) and a.flg(+) = '0';
          這樣 就和
          select * from a left join b on a.id=b.id and a.flg = '0';
          對等了

          # re: oracle 的left join和(+)真的可以起到一樣的效果嗎?[未登錄]  回復  更多評論   

          2011-07-19 09:53 by feng
          oracle 在解析的時候會把left join right join 都轉換成+
          如果你寫sql的時候都是用+就少了轉換
          主站蜘蛛池模板: 晋江市| 钦州市| 攀枝花市| 武功县| 焦作市| 图木舒克市| 交城县| 醴陵市| 防城港市| 法库县| 当阳市| 汉阴县| 佛学| 和顺县| 西吉县| 大渡口区| 若羌县| 海原县| 云梦县| 平潭县| 鄂伦春自治旗| 霍邱县| 山东| 正阳县| 定州市| 汉川市| 芮城县| 蓬溪县| 东阿县| 瓦房店市| 巴青县| 大冶市| 天水市| 嘉定区| 凤翔县| 大厂| 伊宁县| 伊宁市| 阳高县| 迁安市| 辽中县|