Find tables not accessed for past n months in Teradata database

Query below returns list of tables that was not accessed in the last 3 month.

Query

SELECT  DatabaseName,
        TableName,
        LastAccessTimeStamp as LastAccess
FROM    DBC.TablesV
WHERE   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',
        'TD_SYSGPL', 'TD_SYSXML', 'TDMaps', 'TDPUSER', 'TDQCD',
        'tdwm',  'SQLJ', 'TD_SYSFNLIB',  'SYSSPATIAL')
AND LastAccessTimeStamp < CURRENT_DATE - INTERVAL '3' MONTH 
ORDER BY    LastAccessTimeStamp DESC;

Columns

  • DatabaseName - name of the database
  • TableName - name of the table
  • LastAccess - date of last access

Rows

  • One row represents one table in database
  • Scope of rows: all tables not accessed for past 3 months in database
  • Ordered by last access time descending

Sample results

sample results

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