-
Hi
How can one select the last record on a table. Can this be done with just a simple sql statement?
Thanks in advance,
leonard905
leonard905@yahoo.com
-
What do u mean when wrote "LAST RECORD" ?
Last in time?
Last in table? (last row in last db block)
Last in same order of rows?
-
select * from master_control where rowid = (select max(rowid) from master_control).
leonard905
leonard905@yahoo.com
-
Originally posted by leonard905
select * from master_control where rowid = (select max(rowid) from master_control).
What about row, that insert into middle of extent, if some block was in freelist ?
Oracle not always insert rows in block that equal or upper then HWM.
--------------------------------------------------
In addition: Oracle not always allocate next extent for table behind previous one.
[Edited by Shestakov on 03-28-2002 at 02:27 PM]
-
what about
select * from table where rownum = ( select count(*) from table)
F.
-
Originally posted by Mnemonical
select * from table where rownum = ( select count(*) from table)
Never returns anything.
Only meaningful conditions for rownum are
rownum<
rownum<=
rownum=1
The base question is still unanswered: What does LAST RECORD mean?
-
You will never be able to find out the 'last record' inserted unless you have a column in the table with time-stamp for each row inserted. ROWIDs are reused and ROWNUMs simply give a serial number to all records returned by the query.
'Relational' databases do not store records in a particular order (neither do they return them in the order they were inserted.)
For complete and indepth discussion on this question, see
http://www.oracle.com/oramag/oracle/...o61asktom.html
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|