Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PL SQL <table_name> , count(*)

Re: PL SQL <table_name> , count(*)

From: Stephen B <stephen.bell_at_cgi.ca>
Date: Tue, 18 Dec 2001 10:20:42 -0500
Message-ID: <AaJT7.12309$J%2.1587964@news20.bellglobal.com>


Hi Matt,

Here's a simple example which is along the lines the other poster suggested :

I created a small table called rcount on the premise you want to retain the table names and counts in your database :

create or replace procedure counts
as

cursor mycur is select table_name from user_tables;

v_rows number(10,0);

begin

for i in mycur loop

execute immediate ' analyze table '||i.table_name||' compute statistics';

select num_rows into v_rows from user_tables where table_name = i.table_name;

INSERT INTO RCOUNT
VALUES (i.table_name,v_rows);

end loop;
end;
/

I hope this helps!

Steve

"Matt Gross" <mg_redd_at_hotmail.com_NO_SPAM> wrote in message news:9vna6g$2fso$1_at_nwall2.odn.ne.jp...
> I would like to create a pl/sql script which gives me a list of all tables
> and then gives me a count of all rows for each table. Does anyone know
how
> to do this?
>
> Thanks,
>
> Matt
>
>
Received on Tue Dec 18 2001 - 09:20:42 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US