简体   繁体   English

DB2条件导入

[英]DB2 conditional import

I have two DB2 databases (Database1 and Database2) both containing a table called SubscriptionTable. 我有两个DB2数据库(Database1和Database2)都包含一个名为SubscriptionTable的表。 Both tables contain user subscription related data and the columns of SubscriptionTable are the same in both databases. 这两个表都包含与用户订阅相关的数据,并且两个数据库中的SubscriptionTable列均相同。

Now I need to copy (and overwrite) data from Database1.SubscriptionTable to Database2.SubscriptionTable but only if the LAST_UPDATED_TIMESTAMP column in Database2.SubscriptionTable is not greater than a specific date. 现在,仅在Database2.SubscriptionTable中的LAST_UPDATED_TIMESTAMP列不大于特定日期的情况下,才需要将数据从Database1.SubscriptionTable复制(并覆盖)到Database2.SubscriptionTable。

So in short I would like to overwrite subscription data in Database2.SubscriptionTable but only if the data was NOT modified after a specific date. 简而言之,我只想覆盖Database2.SubscriptionTable中的订阅数据,但前提是该数据在特定日期之后未修改。

Could I use existing utility for this purpose, eg db2 import where I could also specify a condition (LAST_UPDATED_TIMESTAMP < 'XXXX-XX-XX') for each row being overwritten ? 我可以为此目的使用现有的实用程序,例如db2 import,其中我还可以为要覆盖的每一行指定一个条件(LAST_UPDATED_TIMESTAMP <'XXXX-XX-XX')吗?

The DB2 IMPORT utility does not have the ability to ignore rows based on what is in them. DB2 IMPORT实用程序不能根据行中的内容来忽略行。

The "easiest" way to do this would be, as Gordon Linoff suggests in the comments, would be via federation, so Database1.SubscriptionTable is accessible from within Database2. 正如戈登·利诺夫(Gordon Linoff)在评论中所建议的那样,做到这一点的“最简单”方法是通过联合身份验证,因此可以从Database2内访问Database1.SubscriptionTable。

Alternatively, you could simply export the data from Database1 that meets your criteria: 或者,您可以简单地从Database1导出满足您条件的数据:

-- Connect to Database1
export to data.del of del select * from SubscriptionTable 
                           where last_updated_timestamp > ...

-- Connect to Database2
import from data.del of del insert into SubscriptionTable ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM