| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to find last record in a table?
"B. Jones" wrote:
>
> Hey, gang.
> I've been relying on a simple little statement that I THOUGHT would
> show me the last record in a table. I found out today that it's
> unreliable (returned records that were inserted on December 12 when
> there were records from today).
> Here's my statement...
> select * from <table> where rowid = (select max(rowid) from <table>);
>
> What do you guys do to find the last record in a table?
>
> Thanks.
In case you haven't caught on from other posts, you need to define 'last'.
In entity-relationship theory and most relational database implementations, there is no inherent concept of order, and especially not 'order of insert'. If you need such an order, it should become an attribute of the entity and therefore a column and therefore sortable.
Suggest you look up the formal definition of 'rowid'. While rowid implies the location of a row, I have not read anywhere that the location needs to be consecutive. Received on Wed Jan 14 2004 - 20:00:10 CST
![]() |
![]() |