1

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
  • I'm afraid what you need is nonsense. Oracle does know it, it is not necessary maintain such an information. Even if there was a way, such a value is usually useless, when running in multi-user concurrent environment. Before the value is sent to you, it can be different in reality. ALL_TABLES view contains a value from the last statistics gathering. Commented May 29, 2015 at 7:41

1 Answer 1

1

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;
Sign up to request clarification or add additional context in comments.

11 Comments

I tried the query you provided, but it gives me Null. But my table is not empty
@user1516815:- Can you show the query which you have tried?
SELECT NUM_ROWS FROM ALL_TABLES WHERE TABLE_NAME = 'STUDENTLOG';
@user1516815:- And what does select count(*) from STUDENTLOG returns?
@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/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.