Home » SQL & PL/SQL » SQL & PL/SQL » Catch a TABLE NAME
Catch a TABLE NAME [message #232792] Mon, 23 April 2007 05:08 Go to next message
barranza
Messages: 2
Registered: April 2007
Junior Member
Hi,
i have a problem.
I have one table containing table names and i would like to count the record of these table and print the table name with record number.

could you please help me ?

Mad
Re: Catch a TABLE NAME [message #232793 is a reply to message #232792] Mon, 23 April 2007 05:11 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
declare
  cnt number;
begin
  for tab in (select table_name from my_table) loop
    execute immediate 'select count(*) from '||tab.table_name into cnt;
    dbms_output.put_line(tab.table_name||':'||cnt);
  end loop;
end;
/

Regards
Michel
Re: Catch a TABLE NAME [message #232795 is a reply to message #232792] Mon, 23 April 2007 05:13 Go to previous messageGo to next message
martijn
Messages: 283
Registered: December 2006
Location: Netherlands
Senior Member
If you gather statistics frequently maybe the easiest way is to look at the column num_rows in table user_tables.

icon10.gif  Re: Catch a TABLE NAME [message #232810 is a reply to message #232792] Mon, 23 April 2007 06:42 Go to previous message
barranza
Messages: 2
Registered: April 2007
Junior Member
Thanks for VERY FAST ANSWER!!!

BOTH SUGGESTIONS WORK FINE.

Matteo

Laughing
Previous Topic: SQL Doubt: Update of salary ALL employees by 10%
Next Topic: How to print my input in excel through pl/sql procedure
Goto Forum:
  


Current Time: Tue Dec 06 00:27:18 CST 2016

Total time taken to generate the page: 0.12557 seconds