oracle中select查询的默认行顺序 [英] Default row ordering for select query in oracle

查看:85
本文介绍了oracle中select查询的默认行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Oracle中,如果未指定"order by"子句,则select查询的默认行顺序是什么.

In Oracle, what is the the default ordering of rows for a select query if no "order by" clause is specified.

  1. 行的插入顺序
  2. 根本没有默认顺序
  3. 以上都不是.

推荐答案

根据汤姆·凯特(Tom Kyte)的说法:除非直到向查询添加"order by",否则您才能对返回的行的顺序一无所知.缺少您不能依赖于返回的行的顺序".

According to Tom Kyte: "Unless and until you add "order by" to a query, you cannot say ANYTHING about the order of the rows returned. Well, short of 'you cannot rely on the order of the rows being returned'."

请参见此问题在asktom.com.

See this question at asktom.com.

对于ROWNUM,它实际上并不存在,因此不能被释放".从表中检索记录后分配ROWNUM,这就是为什么"WHERE ROWNUM = 5"将始终无法选择任何记录的原因.

As for ROWNUM, it doesn't physically exist, so it can't be "freed". ROWNUM is assigned after a record is retrieved from a table, which is why "WHERE ROWNUM = 5" will always fail to select any records.

@ammoQ:您可能想阅读

@ammoQ: you might want to read this AskTom article on GROUP BY ordering. In short:

在查询保证中的Group By子句是否将输出数据 在分组依据"列中排序 订单,即使没有订购依据 条款?

Does a Group By clause in an Query gaurantee that the output data will be sorted on the Group By columns in order, even if there is NO Order By clause?

我们说...

绝对不是,

从来没有,从来没有,从来没有 会.

It never has, it never did, it never will.

这篇关于oracle中select查询的默认行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆