Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 07 May 2002 @ 12:17:24 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: SQL to get table name with row counts?
 
From:   Jim Calvert

Rohit:

What you are asking for can be a bit tricky as it requires a mixture of SQL and dynamically built DDL object names. If you want to count all tables in a certain database, for instance, you somehow need to generate the Select Count(*).... statements for each one and then usually I insert these results into a table.

To generate the counts, I use a statement like :

Select 'Insert into X select '||trim(tablename)||', count(*) from
'||trim(databasename)
||'.'||trim (tablename)||';' from dbc.tables
where databasename = 'foo'
and tablekind = 'T'
order by databasename, tablename;

Then execute the resulting rows. This can be extended to be far more sophisticated.

One day I think I should write a generic stored procedure to do this.

Jim Calvert - NCR Canada



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023