get the list of db2 tables which have been changed since a particular timestamp say since 20120801185856 timestamp

眉间皱痕 提交于 2019-12-05 03:22:59

问题


Is there any way in IBM DB2 to get the list of tables which have been changed(updated/added/deleted) since a specific timestamp?

The problem i am facing is i have restored one backup on 25 July in one box from live db server and updated this restored DB while enabling features packs. Now the live DB server has changed since customer is accessing it and i cannot restore the latest backup as box1 have some addition tables/data.

So i wanted to know the list of tables which have been changed since last backup so that i can update those tables manually. Please help.


回答1:


If you're on DB2 for Linux/Unix/Windows, this query should get what you need:

SELECT TRIM(TABSCHEMA) || '.' || TRIM(TABNAME),
       MAX(CREATE_TIME,ALTER_TIME)
FROM SYSCAT.TABLES
ORDER BY 2 DESC

If you're on the mainframe, this one should do you:

SELECT RTRIM(CREATOR) || '.' || RTRIM(NAME),
       MAX(CREATEDTS,ALTEREDTS)
FROM SYSIBM.SYSTABLES
ORDER BY 2 DESC

However, neither of these will show deleted tables, as they're removed from the system catalog when they are dropped.




回答2:


I would rather suggest a delete trigger recording to a table the details at which a table's delete operation has taken place.



来源:https://stackoverflow.com/questions/11775965/get-the-list-of-db2-tables-which-have-been-changed-since-a-particular-timestamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!