Unanswered: Test data generation with dynamic keys
Can you advice me on the following:
I want to create test data in a test environment by extracting a selection from production data (all related data). Certain tables however have dynamic key fields (the value of a dynamic key field is assigned by db2 upon creation of the row). When adding these records to the table of the test environment the dynamic key fields will have to be recalculated in order to prevent gaps or duplicate keys. Furthermore: other tables are also copied from production because a consistent set is copied. Because the table with the dynamic key field is referenced, the newly calculated value of the dynamic key field will have to be entered in these tables .
Am I correct in these assumptions?
How to perform this operation?
I assume that by "dynamic key fields" youu mean identity columns. If this is the case, create the tables in you test environment with identity columns as "Generated by default" instead of "generated always" This will allow you to insert the data without having to change all the identity columns and all the FK values that pint to them. Also, you will need to set the starting value on you identity column on your test system to something much greater than what you expect your production environment to contain. This will prevent your test system generating values that are duplicate of the production values.