Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Commands to find count of tables and number of rows through command prompt in ORACLE database

Meghana AbhayaJan 19 2024

Hello,

Please help me out in understanding the below commands.

1. To compare the count of tables in the databases, I used the below command

SELECT COUNT(table_name) FROM DBA_TABLES WHERE OWNER IN ('CONFIG','RICALM','RIDW','RIODS');

I got 0 results as I do not have any schemas created in the names of 'CONFIG','RICALM','RIDW','RIODS'.

Is these schemas present by default?

2. Replacing the command with the DB tablespace USER such as 'RM_DB_USER' 'QM_DB_USER','CCM_DB_USER,'JTS_DB_USER I was able to fetch the total table count.

SELECT COUNT(table_name) FROM DBA_TABLES WHERE OWNER IN ('JTS_DB_USER','RM_DB_USER','QM_DB_USER','CCM_DB_USER');

Is it a right way to fetch the table_name count?

  1. The result is consistently 0 for both schema and user, regardless of the specific commands employed.

SELECT OWNER || '.' || TABLE_NAME AS TableNameOracle, NUM_ROWS AS RowCountOracle FROM DBA_TABLES WHERE OWNER IN ('CONFIG','RICALM','RIDW','RIODS') ORDER BY RowCountOracle DESC;

SELECT OWNER || '.' || TABLE_NAME AS TableNameOracle, NUM_ROWS AS RowCountOracle FROM DBA_TABLES WHERE OWNER IN ('JTS_DB_USER','RM_DB_USER','QM_DB_USER','CCM_DB_USER') ORDER BY RowCountOracle DESC;

Regards,

Meghana

Comments
Post Details
Added on Jan 19 2024
5 comments
5,854 views