How to Disable Referential Integrity when loading DB2

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
THEDSKID
Premium Member
Premium Member
Posts: 11
Joined: Thu Apr 29, 2004 10:51 am
Location: DALLAS TX
Contact:

How to Disable Referential Integrity when loading DB2

Post by THEDSKID »

I am in the process of taking a DB2 source, and loading it back to another DB2 table that has RI on another table. The client is ok with breaking the RI in this test environment. What would the syntax be within the DB2 connector to disable RI within the table before loading?
THEDSKID
Premium Member
Premium Member
Posts: 11
Joined: Thu Apr 29, 2004 10:51 am
Location: DALLAS TX
Contact:

Re: How to Disable Referential Integrity when loading DB2

Post by THEDSKID »

Well it looks like I was able to work through this one... Just in case anyone is interested, I simply executed a before sql that dropped the primary key which released the RI, then ran my job which did a Delete and Loaded my recs. I then did an after job sql to re-establish my Primary Key.

Before Sql:
ALTER TABLE XXXX.XXXX DROP PRIMARY KEY

After Sql:
ALTER TABLE XXXX.XXXX ADD PRIMARY KEY (XXXXX)
-Chris
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

If this is only for the TEST env. talk to your DBA. He/She can drop it before your load and recreate them after the load.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Prevention is better than cure. Design your set of jobs so that it does not violate referential integrity.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
MT
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 09, 2007 3:51 am

Re: How to Disable Referential Integrity when loading DB2

Post by MT »

THEDSKID wrote:I am in the process of taking a DB2 source, and loading it back to another DB2 table that has RI on another table. The client is ok with breaking the RI in this test environment. What would the syntax be within the DB2 connector to disable RI within the table before loading?
Hi

well if you talk about DB2 load - it does not care about the defined RI during load but sets a so called check pending state afterwards.
There are option in load to handle this and there is a command (set integrity) to do it explizitly but I strongy recommend to talk to your DBA ...

General speaking I would recommend that you follow Rays advise if you do not use DB2 Load because dropping the primary key and re-creating it is not sufficient to re-establish RI.
regards

Michael
Post Reply