Disordering
Q: Is there any difference in selecting data from Oracle 8i and Oracle 10g? Because in Oracle 10g I'm getting data in a different order. Note: I never used the order by clause in either case.
A: In relational database theory, you are not guaranteed any order. Rows are part of a set and by definition, there is no ordering in a set. If you need a guaranteed order, then you must use the ORDER BY clause. Just because you received the data in a specific order in the past does not guarantee that you will always get that order in the future -- unless you use the ORDER BY clause.
我地發現d report ordering 係oracle8g同oracle10i有分別,而我睇到有ordering問題的都係一d冇寫order by 某個field的query。經理叫我問下公司dba,再問下oracle metalink,有冇d natural ordering的野。當我同個dba傾果時,我地都爆笑,話條query冇用order by,冇disordering都好正常o者~ 唔係仲要問metalink掛? 咁當然老細要我問,我梗問嫁,又唔洗死o既。
不過我都同我阿head講左我同dba的想法先,阿head話佢唔信,佢話一個db一定有一個natural ordering的setting喎!咁唔緊要啦,照問。家下問完返黎,經理自己send返條link出黎,就係以上果段,話唔同order by,出黎的result就梗係唔保證同樣order嫁啦!
認真得啖笑~
A: In relational database theory, you are not guaranteed any order. Rows are part of a set and by definition, there is no ordering in a set. If you need a guaranteed order, then you must use the ORDER BY clause. Just because you received the data in a specific order in the past does not guarantee that you will always get that order in the future -- unless you use the ORDER BY clause.
我地發現d report ordering 係oracle8g同oracle10i有分別,而我睇到有ordering問題的都係一d冇寫order by 某個field的query。經理叫我問下公司dba,再問下oracle metalink,有冇d natural ordering的野。當我同個dba傾果時,我地都爆笑,話條query冇用order by,冇disordering都好正常o者~ 唔係仲要問metalink掛? 咁當然老細要我問,我梗問嫁,又唔洗死o既。
不過我都同我阿head講左我同dba的想法先,阿head話佢唔信,佢話一個db一定有一個natural ordering的setting喎!咁唔緊要啦,照問。家下問完返黎,經理自己send返條link出黎,就係以上果段,話唔同order by,出黎的result就梗係唔保證同樣order嫁啦!
認真得啖笑~


0 Comments:
發佈留言
<< Home