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.
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.
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