Narasimha Maiya
Narasimha Maiya

Reputation: 1029

difference between null and 0 while counting rows

I have a query as follows

select owner, table_name,num_rows from all_tables

for some of the tables num_rows is 0 but for some of the table num_rows is showing null

I'm not getting the difference between these two.

On what condition null will come and when 0 will be displayed?

Thank you

Upvotes: 2

Views: 225

Answers (4)

Narasimha Maiya
Narasimha Maiya

Reputation: 1029

After seeing the helpful answers and comments I did a little search in the internet to come up with following query

ANALYZE TABLE <TABLE_NAME> COMPUTE STATISTICS; 

After executing this query the count is showing 0 for those table which are showing null before.

Thank you for all your inputs.

Upvotes: 0

usman
usman

Reputation: 135

this issue because the those table not analyzed first you need to analyzed those tables then statistics apply on them and this may resolve the issue.

Upvotes: 2

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146558

In the ALL_TABLES reference the NUM_ROWS column is tagged with an asterisk that points to this note:

Columns marked with an asterisk (*) are populated only if you collect statistics on the table with the ANALYZE statement or the DBMS_STATS package.

Upvotes: 1

vercelli
vercelli

Reputation: 4767

I think null is showing on tables without statistics. Last_analyzed should be null too. Try the query with Last_analyzed and check it.

select owner, table_name,num_rows, last_analyzed 
from all_tables;

Upvotes: 3

Related Questions