Home » SQL & PL/SQL » SQL & PL/SQL » last row in a table
last row in a table [message #1836] Mon, 03 June 2002 21:47 Go to next message
sethuraman
Messages: 1
Registered: June 2002
Junior Member
I have a table which does not have a timestamp column. i want to know the row that was last inserted in the table. is there any way to find it.

Thanks in advance
Regards
Sethuraman.R
Re: last row in a table [message #1843 is a reply to message #1836] Tue, 04 June 2002 05:48 Go to previous messageGo to next message
Miguel
Messages: 14
Registered: April 2001
Junior Member
What about

select * from table [[table_name]]
where rowid = (select max(rowid) from [[table_name]])

not sure if it works.
don't do it on a large table.
better add some kind of insert-date field anyway
Re: last row in a table [message #1853 is a reply to message #1836] Tue, 04 June 2002 22:06 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Miguel and sethuraman,
max(ROWID) is no guarantee, that you're selecting the last row. ROWID is the physical ID of that row. It tells Oracle where the row is stored within the datafiles. As Oracle reuses free space (depending on your storage clause of the table definition), a ROWID can also be reused.

If you don't have any audit on the table and no column indicating the creation date of a row, you cannot be sure what row has been inserted last.

MHE
Previous Topic: Sum of Time
Next Topic: is there any gurru of sql/plsql
Goto Forum:
  


Current Time: Fri Apr 26 15:11:31 CDT 2024