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

Home -> Community -> Usenet -> c.d.o.tools -> Re: accessing tables explicitly by index

Re: accessing tables explicitly by index

From: Peter Kallweit <kallweit_at_iief.de>
Date: Thu, 14 Sep 2000 08:26:06 +0200
Message-ID: <39C06F7E.AC55D40B@iief.de>

Hi NiallP,

NiallP wrote:
>
> In Oracle, is there a way to access a single row based on a specific
> index. Here's an example:
> I have a table with a unique index made up from two columns, user_id,
> time_stamp. There may be thousands of rows for each user_id. I want to
> access the most recent row for a particular user_id without having to
> read thousands of rows and finding the max time_stamp. How can this be
> accomplished in Oracle?

select /*+INDEX_DESC(<yourTable> <yourIndex>)*/ * from <yourTable>  where user_id=<yourID> and rownum=1;

HTH
Peter Received on Thu Sep 14 2000 - 01:26:06 CDT

Original text of this message

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