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.

    Query

    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;
    

    Columns

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

    Rows

    • 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

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