简体   繁体   English

DB2中的数据轮换

[英]Data rotation in DB2

The data for reprocessing requests from the previous week gets moved to a back up table on due to which I am unable to reprocess failures that occurs during the weekend. 上周用于重新处理请求的数据已移至备份表,由于该原因,我无法重新处理周末发生的故障。

For a particular table, we have three different identical versions. 对于特定的表,我们有三个不同的相同版本。 Lets say, we have table1 to store the status and id of the documents. 可以说,我们有table1来存储文档的状态和ID。 So we have three identical versions of Table1. 因此,我们有Table1的三个相同版本。

Table1_A 表1_A

Table1_B 表1_B

Table1_C 表1_C

Table1_A will be active for a week and will store all records and on weekend, a script is run and after that Table1_A will be inactive and table1_B (which is empty) will take its place as active table for the week. Table1_A将在一周内处于活动状态,并将存储所有记录,并且在周末运行脚本,此后Table1_A将处于非活动状态,而table1_B (为空)将在一周内成为活动表。 Table1_A will retain data from the previous week. Table1_A将保留前一周的数据。 The following weekend the script will make Table1_C active, Table1_B will retain its data from the previous week and Table1_A will remove all its data. 在下一个周末,脚本将使Table1_C处于活动状态, Table1_B将保留上一周的数据,而Table1_A将删除其所有数据。 Same process will repeat every week. 每周将重复相同的过程。

Since the data pertaining to the previous week is in a table that is not active anymore, we are unable to troubleshoot any failures from the previous week. 由于与前一周有关的数据位于不再有效的表中,因此我们无法对前一周的任何故障进行故障排除。

I have though about copying the previous weeks data from the previous active table to the new active table. 我已经将以前的星期数据从先前的活动表复制到新的活动表中了。 The new active table instead of being empty now will have data from previous week. 现在,新的活动表(而不是空表)将具有上周的数据。

So, my question is what is a good way to copy this data? 因此,我的问题是复制此数据的好方法是什么?

And what are things that I need to worry about while copying this data? 在复制这些数据时,我需要担心什么?

Also, is there a better way to resolve this? 另外,有没有更好的方法来解决这个问题?

Thanks for your help. 谢谢你的帮助。

The described solution is very inflexible. 所描述的解决方案非常不灵活。 You do not describe the reason for doing this but I would urgently recommend to have a look at partitioning Range Partitioning will give you SQL performance and fast roll out of data if this is a concern. 您没有描述执行此操作的原因,但我紧急建议您看一下分区。如果您对此有所关注,Range Partitioning可以为您提供SQL性能并快速推出数据。

When data resides in in Table1_a while Table1_b is active - table1_a is still there and could be queried. 当Table1_b处于活动状态时,当数据驻留在Table1_a中时-table1_a仍然存在并且可以查询。 It may be offline from an application point of view but not from a database point of view. 从应用程序的角度来看,它可能是脱机的,但从数据库的角度来看,它可能不是脱机的。

Without any more business background information I just could recommend to check out table partitioning. 没有更多的业务背景信息,我只是建议您检查表分区。

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

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