I want to take a table row count of a particular table precisely in my application. Rather than running a SQL count query, Is there way to fetch a table row count from oracle database engine?
1 Answer
No there is no way by which you can achieve rows it directly from Oracle database engine.
However if you dont want to use COUNT query then there are other ways by which you can get the result faster in case your table is huge like
SELECT NUM_ROWS FROM ALL_TABLES WHERE TABLE_NAME = your_table_name;
11 Comments
user1516815
I tried the query you provided, but it gives me Null. But my table is not empty
Rahul Tripathi
@user1516815:- Can you show the query which you have tried?
user1516815
SELECT NUM_ROWS FROM ALL_TABLES WHERE TABLE_NAME = 'STUDENTLOG';
Rahul Tripathi
@user1516815:- And what does select count(*) from STUDENTLOG returns?
Rahul Tripathi
@user1516815:- If you want you can use the
exec DBMS_STATS.GATHER_DATABASE_STATS; This will update the statistics. You can refer this: docs.oracle.com/cd/B28359_01/appdev.111/b28419/… |
ALL_TABLESview contains a value from the last statistics gathering.