DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: last record

  1. #1
    Join Date
    Jun 2000
    Location
    dumfries,va,usa
    Posts
    227
    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

  2. #2
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    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?


  3. #3
    Join Date
    Jun 2000
    Location
    dumfries,va,usa
    Posts
    227
    select * from master_control where rowid = (select max(rowid) from master_control).

    leonard905
    leonard905@yahoo.com

  4. #4
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    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]

  5. #5
    Join Date
    Dec 2001
    Location
    Brazil
    Posts
    282


    what about

    select * from table where rownum = ( select count(*) from table)



    F.

  6. #6
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712
    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?

  7. #7
    Join Date
    Aug 2001
    Location
    Waterloo, On
    Posts
    547
    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


    Raminder Singh

    Oracle Certified DBA: Oracle 8i, 9i


    Mail me at raminderahluwalia@rediffmail.com.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width