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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Order rows

RE: Order rows

From: Lord, David - CSG <David.Lord_at_hayscsg.com>
Date: Wed, 15 May 2002 00:43:17 -0800
Message-ID: <F001.00460C60.20020515004317@fatcity.com>


Use a sequence...

SQL> create sequence mysequence;
SQL> alter table abc add (sequence_no number);
SQL> insert into abc(sequence_no, a) values (mysequence.nextval, 500);
...
SQL> select a from abc order by sequence_no;

Using a date column will only give you accuracy down to a whole second.

> -----Original Message-----
> From: systems_ho/VGIL_at_vguard.satyam.net.in
> [mailto:systems_ho/VGIL_at_vguard.satyam.net.in]
> Sent: 15 May 2002 07:08
> To: Multiple recipients of list ORACLE-L
> Subject: Order rows
>
>
> Hi All
>
> Is there any method in Oracle to capture or order the rows in
> a table in
> the order they were entered.
> I tried it with rowid but when a row is deleted, the rowid
> corresponding to
> this row is reassigned for a new row
> which is inserted into the table at a later stage.
>
> Eg.
>
> SQL> select rowid,abc.* from abc order by rowid;
>
> ROWID A
> ------------------ ----------
> AAAFmYAASAAAYsqAAA 100
> AAAFmYAASAAAYsqAAB 200
> AAAFmYAASAAAYsqAAC 300
>
> I deleted one transaction.
>
> delete from abc where a=200;
> commit;
>
> Then I inserted two rows.
>
> insert into abc values(500);
> insert into abc values(600);
> commit;
>
> Now when I order by rowid
>
> SQL> select rowid,abc.* from abc order by rowid;
>
> ROWID A
> ------------------ ----------
> AAAFmYAASAAAYsqAAA 100
> AAAFmYAASAAAYsqAAB 600
> AAAFmYAASAAAYsqAAC 300
> AAAFmYAASAAAYsqAAD 500
>
> I.e The values I entered last appeared second.The rowid
> (AAAFmYAASAAAYsqAAB
> ) corresponding to the row I deleted was reassigned for the
> last entered
> row (a=600).
> What I want is that this must be sorted in the order of its entry.
> Can anyone help me out.
> Thanks in advance
> Systems.
>
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author:
> INET: systems_ho/VGIL_at_vguard.satyam.net.in
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
>



This message (including any attachments) is confidential and may be legally privileged. If you are not the intended recipient, you should not disclose, copy or use any part of it - please delete all copies immediately and notify the Hays Group Email Helpdesk at email.helpdesk_at_hays.plc.uk
Any information, statements or opinions contained in this message (including any attachments) are given by the author. They are not given on behalf of Hays unless subsequently confirmed by an individual other than the author who is duly authorised to represent Hays.  

A member of the Hays plc group of companies. Hays plc is registered in England and Wales number 2150950. Registered Office Hays House Millmead Guildford Surrey GU2 4HJ.


-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Lord, David - CSG
  INET: David.Lord_at_hayscsg.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed May 15 2002 - 03:43:17 CDT

Original text of this message

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