The plan is to identify unused tables in db2 z o/s , is there any way we can get last accessed date of each table in db2 z o/s. [ in db2 LUW we have last_used column in syscat.tables but in db2 z o/s we dont any last used column in sysibm.systables ]
how to get last accessed date of a table in db2 z o/s?
966 views Asked by maseed ilyas At
1
Db2 zOS doesn't keep that kind of information in catalog tables, you probably do NOT really want Db2 to keep updating that kind of information to the catalog for every individual access from performance overhead (although it is tiny) and MIPS consumption point of view.
On the other hand, there are some ways to identify the unused table.
If you know all tables suppose be updated (insert/delete/update), no read only tables on your system, then you can monitor SYSTABLESPACESTATS (which is real time stats table, you can issue ACCESS DB command to dump it or let Db2 dump it on certain conditions) for a period, like 30 days or 90 days, to potentially identify which tables are no longer used, then mark it as candidate, to be safe, don't drop it immediately.
If some unused tables can be read only and you want to identify, you probably have to use AUDIT trace to monitor FIRST READ on the table. In order to do that, you also need to make sure your tables are not in AUDIT NONE/CHANGES state, if some tables are in AUDIT NONE/CHANGES state, you can issue ALTER TABLE to change them to AUDIT ALL, then turn on the AUDIT trace (143 and 144) to monitor the access for like 30 days or 90 days.