Today I leant how to gather statistics for a table. For this I have created a table and inserted some records into the table. Then I queried the DD(Data Dictionary) table with the following query.
Select num_rows from USER_TABLES WHERE TABLE_NAME = 'SOMA';
Obviously this didn’t give any result about the number of rows in the table.
If you want the above query to return the number of rows for a table, you have to gather statistics for that table.
In order to gather statistics, I used the following statement.
analyze table soma compute statistics;
I got the output that ‘TABLE ANALYZED’
Then I checked the output of the query.
Select num_rows from USER_TABLES WHERE TABLE_NAME = 'SOMA';
NUM_ROWS
-------------
6
No comments:
Post a Comment