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 ]
1 Answers
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.

- 26
- 2
-
currently we are making use of lastused column from sysibm.sysindexspacestats table to get last accessed date for tables. but only issue here is we will get access details for tables that have indexes. For tables without index we wont get last accessed date – maseed ilyas Jun 17 '21 at 11:21