Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to find last record in a table?

Re: How to find last record in a table?

From: Mladen Gogala <mgogala_at_adelphia.net>
Date: Thu, 15 Jan 2004 05:15:14 GMT
Message-Id: <pan.2004.01.15.05.16.44.142234@adelphia.net>


On Wed, 14 Jan 2004 11:03:37 -0800, 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.

Usually by reading all the records that precede it. What do you mean by "last record"? Last stored? Last retrieved? Relational databases are modeled after relational algebra, which means that they deal with subsets. Subsets are, generally speaking, not ordered (although every set can be well ordered, but that's another story indeed), unless we introduce ordering. Then we use the term "minimum" or "maximum", not the "last record". In relational database one defines a subset, by specifying all the elements. Unless subset is ordered, the word "last" has no meaning. Ordering is a transitive relation on set A with the following properties:
1) (a<b) & (b<a) => a=b, for all a,b in A 2) (a<b) & (b<c) => a<c for all a,b,c in A (transitivity)

If there no a in A so that a<a, then the ordering is called "strict". If each element in A has the immediate successor, then we are talking about well ordering relation. After that story gets extremely non-trivial. Masochists can read Seymour Lipschutz's "Set Theory" for further clarifications.

-- 
None of us is as dumb as all of us.
(http://www.despair.com/meetings.html)
Received on Wed Jan 14 2004 - 23:15:14 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US