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: Kevin A Lewis <Kevin_A_Lewis_at_Hotmail.com>
Date: Mon, 17 Jan 2000 09:26:59 GMT
Message-ID: <DfBg4.2060$hr4.28923@newreader.ukcore.bt.net>


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 - 03:26:59 CST

Original text of this message

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