0

May order of rows in unordered query (like select * from smth) be different in different queries (in the same and not same session) if there are no updates to database table?

michael nesterenko
  • 14,222
  • 25
  • 114
  • 182
  • I'm no oracle expert but I suspect they depend on your indexing. If you need a specific ordering then user order by. – Ross Dargan Oct 26 '11 at 09:33

1 Answers1

3

The order or rows returned from a query should never be relied upon unless you have included a specific ORDER BY clause in your query.

You may find that even without the ORDER BY the results appear in the same order but you could not guarentee this will be the case and to rely on it would be foolish especially when the ORDER BY clause will fulfill your requirements.

See this question: Default row ordering for select query in oracle

It has an excellent quote from Tom Kyte about record ordering.

So to answer your question: Yes, the order of rows in an unordered query may be different between queries and sessions as it relies on multiple factors of which you may have no control (if you are not a DBA etc.)

Hope this helps...

Community
  • 1
  • 1
Ollie
  • 17,058
  • 7
  • 48
  • 59