Anish Budha
Anish Budha

Reputation: 3

In Oracle SQL developer, how can I find the number of rows in a certain table?

I just wanted to know how do I can I find the number of rows in a certain table.

Upvotes: 0

Views: 1009

Answers (2)

Littlefoot
Littlefoot

Reputation: 142705

Apart from the obvious count function, if you regularly gather schema statistics, you can - at least approximately (if tables' contents change relatively frequently) - query user_tables and check the num_rows column's contents:

SQL> exec dbms_stats.gather_schema_stats('SCOTT');

PL/SQL procedure successfully completed.

SQL> select table_name, num_rows from user_tables;

TABLE_NAME             NUM_ROWS
-------------------- ----------
EMP                          14
DEPT                          4
BONUS                         0
SALGRADE                      5
INVOICE                       4
ERRORS                      110
DAT                           0
<snip>

Is that really so? For example:

SQL> select count(*) from emp;

  COUNT(*)
----------
        14

SQL> select count(*) from dept;

  COUNT(*)
----------
         4

SQL> select count(*) from bonus;

  COUNT(*)
----------
         0

SQL> select count(*) from errors;

  COUNT(*)
----------
       110

SQL>

Upvotes: 0

MT0
MT0

Reputation: 167972

Use the COUNT aggregation function:

SELECT COUNT(*) FROM table_name;

Upvotes: 1

Related Questions