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: What is the order of query result by default ?

Re: What is the order of query result by default ?

From: Maxim Demenko <mdemenko_at_gmail.com>
Date: Wed, 06 Sep 2006 19:01:12 +0200
Message-ID: <edmusn$jc8$01$1@news.t-online.com>


krislioe_at_gmail.com schrieb:
> Hi All,
>
> If I do : select * from myTable, is it guaranteed that the query
> resultset is always the order when the data is inserted into the table
> ?

In Oracle it is guaranteed, that you have *no guarantee* in ordering of result set retrieved from heap organized tables unless you specify ORDER BY clause
> For example :
>
> create table myTable(col1 varchar(2) primary key)
>
> Insert into mtTable values('x4')
> Insert into mtTable values('x3')
> Insert into mtTable values('x1')
> Insert into mtTable values('x2')
>

You can not rely on this order, it depends on a lot of factors, the only reliable possibility is to specify ORDER BY clause
> select * from myTable // without any where condition.
WHERE condition is irrelevant to order of data set
>
> then the query result is ALWAYS :

As somebody said, ALWAYS IS NEVER TRUE, NEVER IS ALWAYS FALSE ;-)
> x4
> x3
> x1
> x2
>
> Thank you ,
> xtanto
>

Best regards

Maxim Received on Wed Sep 06 2006 - 12:01:12 CDT

Original text of this message

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