Home Page for the TeradataForum

Archives of the TeradataForum

Message Posted: Tue, 07 May 2002 @ 12:23:38 GMT

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

Subj:   Re: SQL to get table name with row counts?
From:   Ulrich Arndt


A very quick, dirty and ugly solution :-) and I can not recommend to use it against the whole production database.

First: generate SQL with the SQL below and export it to a file (adjust the database list)

Second: execute the generated SQL.

select (case when id1 <> 1 then 'union all ' else '' end) !! /* first table no union */
         sql !!
         (case when id2 <> 1 then '' else ';' end) as sql /* last table ; */
from (
        select csum(1,tablename) as id1, /* first table */
                 csum(1,tablename desc) as id2, /* last table */
                'select cast(''' !! trim(databasename) !! ''' as
varchar(30)) as databasename, cast(''' !! trim(tablename) !! ''' as
varchar(30)) as tablename, count(*) as rowcount from '!!
!! '.'!! trim(tablename) !! ' group by 1' as sql
        from dbc.tables
        where databasename in ('X','Y')
                and tablekind = 'T'

) as tmp
order by id1

Kind regards


  <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