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

Home -> Community -> Usenet -> c.d.o.misc -> Re: query for # of rows - fuller explanation

Re: query for # of rows - fuller explanation

From: Roger Stapley <rstapley_at_uk.oracle.com>
Date: Mon, 17 Jan 2000 10:00:11 +0000
Message-ID: <3882E82B.4ED72866@uk.oracle.com>


You could use SELECT COUNT(1) FROM TABLE; which doesn't need a not null column.

Roger Stapley.

Kevin A Lewis wrote:
>
> The last post is the correct answer only if you consider the issue of null
> entries which will not get included, thus missing some rows.
>
> Also do not get distracted by the NUM_ROWS column on the DBA_TABLES view,
> this is built when you ANALYZE STATISTICS for the table or even the whole
> schema. It suffers from either being imprecise (estimated statistics) or out
> of date (last statistics run).
>
> If you have a primary key to the table SELECT COUNT(primary_key_name)
> FROM table;
>
> Alternatively any column which has a NOT NULL constraint should give you a
> full row count.
>
> Otherwise SELECT COUNT(*) FROM table; is the only reliable option.
>
> Unless someone knows something I don't that is - always possible.
>
> Regards
>
> --
> Kevin A Lewis (BOCM PAULS LTD) - Animal Feed Manufacturer - Ipswich United
> Kingdom)
> <Kevin_A_Lewis_at_Hotmail.com>
>
> The views expressed herein by the author of this document
> are not necessarily those of BOCM PAULS Ltd.
> <dbrah_at_my-deja.com> wrote in message news:85p1jr$5lm$1_at_nnrp1.deja.com...
> > Is there a command to query a table for the number of rows without
> > having to do SELECT *?
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
Received on Mon Jan 17 2000 - 04:00:11 CST

Original text of this message

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