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: 68722
Registered: March 2007
Location: Saint-Maur, France, https...
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: 286
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: Thu Dec 12 23:04:27 CST 2024