0 pts.
 Oracle query to count rows in tables
Does anyone have a PL/SQL script to count the rows in all the tables in a given schema? No use reinventing the wheel... TIA, Mike

Software/Hardware used:
ASKED: May 27, 2005  12:22 PM
UPDATED: May 27, 2005  12:55 PM

Answer Wiki:
If you don't absolutely need it in a plsql script, and you are just using the information for occasional review, this simple sqlplus script would work. Save the following in a text file: buildscript.sql set pagesize 0 connect schemaname/schemapswd spool c:tablecnt.sql SELECT 'select ''' || table_name || ': '', count(*) from ' || table_name || ';' from user_tables; spool off @c:tablecnt In Sqlplus, run the buildscript.sql file. The script will first build a new script file and then execute the new script giving the table name and its count. Remember to enter the correct schema name and password in the connect statement.
Last Wiki Answer Submitted:  May 27, 2005  12:55 pm  by  Randym   1,740 pts.
All Answer Wiki Contributors:  Randym   1,740 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _