Home » SQL & PL/SQL » SQL & PL/SQL » To retrieve Table names and no of Rows in each table
To retrieve Table names and no of Rows in each table [message #223950] Mon, 12 March 2007 06:48 Go to next message
raje.vinayak
Messages: 10
Registered: January 2007
Location: thane
Junior Member
Friends,

Can u write a query to Retrieve table names and no of rows in each table

e.g

table_name rows
EMP 14
Dept 4
Salgrade 5

etc.

Here is my Query

--Query to Retrieve Table Names and Rows in each table

declare
cursor c1 is select tname from tab;
t1 c1%rowtype;
t2 varchar2(30);
r number;

BEGIN

open c1;

loop
fetch c1 into t1;
t2:=t1.tname;
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || t2 || '''' INTO r;
dbms_output.put_line(t1.name || ' rows ' || r );
exit when c1%notfound;
end loop;
end;


PLz send u r quieries
or if u ve any solution for this


thanks
vinayak
Re: To retrieve Table names and no of Rows in each table [message #223961 is a reply to message #223950] Mon, 12 March 2007 07:38 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
if your statistics are up to date, try the following

select table_name,NUM_ROWS
from user_tables;
Previous Topic: Query to calculate working hours
Next Topic: date problem
Goto Forum:
  


Current Time: Thu Dec 08 08:25:29 CST 2016

Total time taken to generate the page: 0.14238 seconds