Home » SQL & PL/SQL » SQL & PL/SQL » number of records in each table
number of records in each table [message #495] Fri, 15 February 2002 11:14 Go to next message
SANDY
Messages: 60
Registered: April 1998
Member
Hi,
Say I have 60 different tables in my database. How can I find number of records in each table ?

Following query fetches name of table and count(*) as 1 in for all tables

select table_name, count(*)
from (select table_name from all_tables)
group by table_name

Help me please ...
Sandy
Re: number of records in each table [message #496 is a reply to message #495] Fri, 15 February 2002 13:02 Go to previous message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
save this script in a file and execute (say cnt.sql)

set term off
set feed off
set pagesize 0
set newpage none
set echo off
spool table_count.sql
select 'PROMPT TABLE : '||table_name||chr(10)||'select ''Number of records '' ||count(*) from '||table_name||';'
from user_tables;
spool off
set term on
@table_count.sql

SQl>@cnt.sql
Previous Topic: DEBUG ROUTINE
Next Topic: Check for existence of table, if not there, create, if there, update
Goto Forum:
  


Current Time: Fri Apr 26 04:27:38 CDT 2024