Oracle query to count rows in tables

pts.
Tags:
Oracle
SQL
T-SQL
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following