1. Registered User
Join Date
Mar 2005
Posts
25

Hi

How can I get the number of lines/registers in a table, without making: select count(*) from table

Regards

2. Registered User
Join Date
Aug 2003
Location
Where the Surf Meets the Turf @Del Mar, CA
Posts
7,776
You could take the total weight of the table and divide that number by the average weight of a single row.
The resultant number will be the number of rows in the table.

3. Registered User
Join Date
May 2004
Location
BA [ARG]
Posts
137
Originally Posted by anacedent
You could take the total weight of the table and divide that number by the average weight of a single row.
The resultant number will be the number of rows in the table.
Let me add, you'll need to maintain statistics for that.

4. Registered User
Join Date
Jun 2004
Location
Liverpool, NY USA
Posts
2,520
Originally Posted by anacedent
You could take the total weight of the table and divide that number by the average weight of a single row.
The resultant number will be the number of rows in the table.
LOL....

In otherwords, how the heck is oracle supposed to know how many rows if you have never scanned the table. You can do statistics on the table and get close to the number of rows or you perform a count or you can dump the table, there is no other way.

5. Registered User
Join Date
May 2004
Location
BA [ARG]
Posts
137
What's the real question behind this?

6. Registered User
Join Date
Mar 2005
Posts
25
When quering a table, it has the field num_rows but it empty when I try to get the value.

7. Registered User
Join Date
Aug 2003
Location
Where the Surf Meets the Turf @Del Mar, CA
Posts
7,776
>it has the field num_rows but it empty when I try to get the value.
Yes, this is normal & expected behavior.
All fields start out empty until data is inserted/updated into the field.
Oracle can not mind read & automagically update fields with "correct" values.
Simply put, if you want to really know the number of rows in TABLE_A, then
SELECT COUNT(*) FROM TABLE_A;
Why are you reluctant to do so?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•