Row count for all tables in a database

Database

Row count for all tables in a database


Hello,

I am new to Teradata.

Can some one please tell me how to determine the row count for all tables in a database schema? In Oracle I'd use:
select table_name, num_rows from user_tables;

I researched tables in DBC (TableSize, Columns, etc.) but could not come up with how the required information can be generated.

Thanks,
SB

2 REPLIES
Enthusiast

Re: Row count for all tables in a database

[font=Verdana][/font]
Hi,

I dont think there is direct way to get the row counts form any of the DBC tables. Here is the query that you may use:

Select 'Select '''||trim(tablename)||''',count(*) from '||trim(databasename)||'.'||trim(tablename)||';'
from dbc.tables
where databasename=' ';

This would return the Select statements which you can execute it in SQL assistant

Re: Row count for all tables in a database

No offense....but this is crazy? It is so simple in oracle and sql server.

The above example still doesnt really work.  You would still have modify the statement more and add union all.

Then copy all the output window to another sql asst session.

THere has to be simplier code