DB version: 11.2.0.4
I have few tables in my schema. I need to run count(*) on each table and then add them up.
In the below example I am manually running COUNT(*) on each table and sum it up and I get 23. Can I do this using PL/SQL or SQL ?
I don't want to use user_tables.num_rows for this purpose because num_rows is accurate only when the stats are up-to-date.
SQL> show user
USER is "SCOTT"
SQL>
SQL>
SQL> select table_name from user_tables;
TABLE_NAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
SQL> select count(*) from DEPT;
COUNT(*)
----------
4
SQL> select count(*) from EMP;
COUNT(*)
----------
14
SQL> select count(*) from BONUS;
COUNT(*)
----------
0
SQL> select count(*) From SALGRADE;
COUNT(*)
----------
5
SQL> select 4+14+0+5 from dual;
4+14+0+5
----------
23