Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: order by in a view Help Please
On Mon, 6 Jul 1998 16:19:24 +0100, "Mujahid Hamid"
<mujahid_at_pharmco.demon.co.uk> wrote:
>Dear all,
>
>I am trying to use order by in a view but I get Ora 00933 (sql not properly
>ended)
>
>When I use the following I get errors:
>for example
>
> 1.Create view test
> select name, address from customer
> order by name
>2. create table customer_1 as select * from customers
> order by name,
>3. insert into customer select * from old_customer
> order by name
>
>how can I create a sorted table from an unsorted table ?
>
>Thanks for you help
>
>Mujahid
>
>
>
Oracle doesn't guarantee that the order of the rows retrieved by a SELECT statement is the same as the order which was used to insert the rows on the table. You should make no assumptions of any kind about the order of the rows retrieved when you don't use the ORDER BY clause. You should instead consider that the rows are randomly given to you.
Thus, whenever you want your output to be ordered, you must explicitly use the ORDER BY clause. That's why Oracle doesn't allow issuing the 3 statements above.
Hope this helps,
Nuno Guerreiro Received on Mon Jul 06 1998 - 10:55:03 CDT
![]() |
![]() |