Re: Finding num_rows in user_tables
Date: 1995/10/13
Message-ID: <ALAW.95Oct13020030_at_ap283sun.us.oracle.com>#1/1
In article <DGCLtE.DMG_at_ranger.daytonoh.attgis.com> Nalini Vallampati <nalini.vallampati_at_daytonoh.attgis.com> writes:
> Hi all, this may be a silly question so please bear with me.
> When I type
>
> select table_name, num_rows from user_tables;
>
> why do I get null values for num_rows ?
num_rows is populated only after you've analyzed the table, and that number doesn't change when you subsequently insert and delete from the table.
> How can I find, using just one sql statement, the table_name and the
> number of rows within each table ?
To have the accurate row count of a table, the best way is to use count(1). It would help if there is a unique index on the table since you can fool the optimizer into doing a full index scan instead of a full table scan to get the count.
-- "Everything that can be said about Win95 has been said... The Win95 user interface is not nearly as good as the Mac. Blah, blah. It has all been said a thousand times." - Larry Ellison Alvin W. Law ........................................... Oracle Corporation Senior Technical Consultant ................ 300 Oracle Parkway, Box 659305 Applications Design & Architecture ............... Redwood Shores, CA 94065 Email: alaw_at_oracle.com ...... Voice: +1.415.506.8317 . Fax: +1.415.506.7294Received on Fri Oct 13 1995 - 00:00:00 CET