Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: general question

Re: general question

From: Wanderley M Ceschim <wces123_at_yahoo.com>
Date: Sat, 28 Dec 2002 03:01:03 GMT
Message-ID: <Pt8P9.57913$6H6.2013447@twister.austin.rr.com>


sk wrote:
> I know it is not the way the data is actually stored. If I do a "select
> *", I believe I get the correct order. I am trying to understand
> why/how the system provides the result seemingly sorted as stated below.
>
>
>
> Jim Kennedy wrote:
>
>

>>Pure chance.  Don't rely on it.
>>Jim
>>"sfk" <stefano1_at_att.net> wrote in message
>>news:3Q6P9.81319$hK4.6680146_at_bgtnsc05-news.ops.worldnet.att.net...
>>
>>>Using 9i SQL on HR employees table, perform
>>>
>>>SELECT LAST_NAME FROM EMPLOYEES
>>>
>>>why do the names sort out alphabetically asc? Is there a default
>>>working?
>>>
>>>
>>>

>
>

Most likely you have an index on the LAST_NAME column, in which case Oracle will get the LAST_NAME values directly from the index (and therefore will show the results in order) using a fast full index scan and will never even touch the table. You'll see that if you run the query in sqlplus with "SET AUTOTRACE ON".

This would account for the difference if you "SELECT *", because in this case Oracle would have to access the table directly and will show you the data in the order it is layed out in the data blocks.

The only way to guarantee a specific order is to use ORDER BY. Received on Fri Dec 27 2002 - 21:01:03 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US