How to count total row count for each table in entire database

Database
Enthusiast

How to count total row count for each table in entire database

Hi, My Name is T-Nguyen, a new bee for teradata. Using SQL assistance.

Any one able to help me with SQL to find out how many row for each table in the database. i am so tire to do simple count SQl for each table.

Appreciated so much
1 REPLY
Enthusiast

Re: How to count total row count for each table in entire database

Hi,

when I want to count,
I generate a query by using following SQL:

Select 'Select ''' || Database_Id || ''', ''' || Name || ' '', Count(*) From ' || Trim(Database_Id) || '.' || Trim(Name) || ' Union'
From (Select DatabaseName, TableName
From dbc.tables
where databasename like 'PRD_%'
and tablekind = 'T'
Group by 1, 2
) As Counting(Database_Id, Name)
;

--> Just change the databasename (here everything that starts with PRD_)
--> Cut and paste the result of this query (delete the last Union of the last row)
--> Executes the 'result'