IBM DB2 Query Toolbox - Find tables not accessed for past n months



Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

IBM Db2 Query Toolbox - Find tables not accessed for past n months in Db2 database

A consulta abaixo retorna uma lista de tabelas que não foram acessadas no último mês n.
Query below returns list of tables that was not accessed in the last n month.

Consulta - 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;

Colunas

  • tabela - nome do esquema da tabela e tabela
  • last_used - dados do último acesso de uso

Linhas

  • Uma linha representa uma tabela no banco de dados
  • Escopo das linhas: todas as tabelas não acessadas nos últimos 6 meses no banco de dados
  • Ordenado por esquema de tabela e nome de tabela

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

Resultado - Sample results


Copyright © Dataedo.