Find tables not accessed for past n months in Db2 database

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


select tabschema || '.' || tabname as table,
       lastused as last_used
from syscat.tables 
where tabschema not like 'SYS%'
      and lastused < (current date - 6 MONTHS) 
      and type = 'T'
order by lastused desc;


  • table - name of the table's schema and table
  • last_used - datet of last access use


  • One row represents one table in database
  • Scope of rows: all tables not accessed for past 6 months in database
  • Ordered by table schema and table name

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.
There are no comments. Click here to write the first comment.