Find tables not accessed for past n months in Db2 database

Bart Gawrych - Dataedo Team Bart Gawrych 2019-01-17

Table of Contents:

    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

    There are no comments. Click here to write the first comment.

    By continuing to use our website, you consent to the use of cookies in accordance with our Privacy Policy (updated 28-04-2020).