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 -> Select Statement

Select Statement

From: eye1h <eye1h_at_yahoo.com>
Date: 21 Apr 2006 06:32:47 -0700
Message-ID: <1145626367.886473.81090@i40g2000cwc.googlegroups.com>


Good Morning Gentleman,

Requirment:
Need to check whether there Is a record satisfying given criteria
(transnum = :Itransnum;) in a 10 million row table.
(lets assume this records can exist as the first row or last row). All
I want is to find out if this row exists. But my problem is evne if this is the first row Oracle still continues going through 10 million records. Am i writing the select correct?

SELECT COUNT(*)
INTO :Icount
FROM archive_tbl
WHERE transnum = :Itransnum;

The above willl go through all the records... which is not optimal. I
want to get out when a single row is found. The following also DOES NOT
do the trick....it scannes the entire rows...

SELECT COUNT(*)
INTO :Icount
FROM archive_tbl
WHERE transnum = :Itransnum and rownum=1;

Any better way of writing this? Your help is very much appreciated.

Cheers
Ivan Received on Fri Apr 21 2006 - 08:32:47 CDT

Original text of this message

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