| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: query for # of rows - fuller explanation
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
![]()  | 
![]()  |