Home » SQL & PL/SQL » SQL & PL/SQL » Sorting (Oracle 10g)
Sorting [message #420905] Thu, 03 September 2009 03:47 Go to next message
mamalik
Messages: 266
Registered: November 2008
Location: Pakistan
Senior Member

Dear All,

A table has more than 100 records. Table has no serial number column. How can i find out that which record entered first in table.

Regards.
Asif.
Re: Sorting [message #420906 is a reply to message #420905] Thu, 03 September 2009 03:52 Go to previous messageGo to next message
ThomasG
Messages: 3186
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
You can't.
Re: Sorting [message #420907 is a reply to message #420905] Thu, 03 September 2009 03:59 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
To paraphrase a regular poster here,
I have a bag full of balls. These balls have no distinguishing features. How can I tell which order they were put in the bag?

[Edited because I can't spall]

[Updated on: Thu, 03 September 2009 04:00]

Report message to a moderator

Re: Sorting [message #421066 is a reply to message #420905] Fri, 04 September 2009 01:08 Go to previous messageGo to next message
mamalik
Messages: 266
Registered: November 2008
Location: Pakistan
Senior Member

Sir,
Thanks . Can rowid or rownum not help us for this?

Regards.
Asif.
Re: Sorting [message #421067 is a reply to message #420905] Fri, 04 September 2009 01:14 Go to previous messageGo to next message
BlackSwan
Messages: 24917
Registered: January 2009
Senior Member
>Can rowid or rownum not help us for this?
Either it can & you do not have a problem or no it can not.
You can decide which is the answer.
It is not our problem or our decision.
Re: Sorting [message #421068 is a reply to message #421066] Fri, 04 September 2009 01:56 Go to previous message
flyboy
Messages: 1831
Registered: November 2006
Senior Member
mamalik wrote on Fri, 04 September 2009 08:08
Can rowid or rownum not help us for this?

If you would have a look into SQL Reference book (part of Oracle documentation, available e.g. online on http://tahiti.oracle.com/), you would find their description.
Quote:
ROWNUM Pseudocolumn
For each row returned by a query, the ROWNUM pseudocolumn returns a number indicating the order in which Oracle selects the row from a table or set of joined rows. The first row selected has a ROWNUM of 1, the second has 2, and so on.

In given example with bag full of balls, this is the order in which you take the ball from the bag.
Quote:
ROWID Pseudocolumn
...
You should not use ROWID as the primary key of a table. If you delete and reinsert a row with the Import and Export utilities, for example, then its rowid may change. If you delete a row, then Oracle may reassign its rowid to a new row inserted later.

This is the place where the ball is actually placed. Anyway, it might change its place during time, e.g. take the free place of the ball which was removed.

You may use it, but its result may be incorrect. As you are unable to identify it too, how would you check it?
Previous Topic: Help In Oracle SQL in converting GMT to EST with DST and Date Offset
Next Topic: ROWNUM not getting from the table
Goto Forum:
  


Current Time: Sat Oct 01 17:51:27 CDT 2016

Total time taken to generate the page: 0.07872 seconds