本文介绍了获取自特定时间戳以来已更改的 db2 表的列表,例如自 20120801185856 时间戳以来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IBM DB2 中是否有任何方法可以获取自特定时间戳以来已更改(更新/添加/删除)的表的列表?

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

我面临的问题是我在 7 月 25 日从实时数据库服务器的一个盒子中恢复了一个备份,并在启用功能包的同时更新了这个恢复的数据库.现在实时数据库服务器已经改变,因为客户正在访问它,我无法恢复最新的备份,因为 box1 有一些附加表/数据.

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.

推荐答案

如果您使用的是 DB2 for Linux/Unix/Windows,这个查询应该能得到您需要的:

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.

这篇关于获取自特定时间戳以来已更改的 db2 表的列表,例如自 20120801185856 时间戳以来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 10:39