List tables by the number of rows in Teradata database

In Teradata to identify row number of table, firstly we need to collect statistic by COLLECT STATISTICS statement


COLLECT STATISTICS INDEX(address_id) ON Person.Address ;

To read more visit official documentation


This query may not return exact row number and can be very diffrent from real result, because it depends on collect statistics time.

Query below returns list of tables in a database with their number of rows at the time statistic was collected.


SELECT  DatabaseName,
FROM    DBC.TableStatsV
WHERE   IndexNumber = 1
AND DataBaseName NOT IN ('All', 'Crashdumps', 'DBC', 'dbcmngr', 
    'Default', 'External_AP', 'EXTUSER', 'LockLogShredder', 'PUBLIC',
    'Sys_Calendar', 'SysAdmin', 'SYSBAR', 'SYSJDBC', 'SYSLIB', 
    'SystemFe', 'SYSUDTLIB', 'SYSUIF', 'TD_SERVER_DB',  'TDStats',
    'tdwm',  'SQLJ', 'TD_SYSFNLIB',  'SYSSPATIAL')
ORDER BY    RowCount DESC;


  • DatabaseName - database name
  • TableName - name of the table
  • RowCount - number of rows in a table at stats collect time
  • LastCollectTimeStamp - date when stats were collected


  • One row represents one table
  • Scope of rows: all tables on which stats was collected in a database
  • Ordered by number of rows descending

Sample results

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
There are no comments. Click here to write the first comment.