views:

570

answers:

2

Hello people,

I have to copy tables from an Oracle database to a db2 v7 one, and in order to do this (avoiding millions of drops and creates) I'd like to know if db2 has a feature like Oracle to enable / disable constraints temporarily without dropping them.

Thanks in advance, Mauro.

+1  A: 

I'm not sure if this works in version 7, but you can try the following:

set integrity for table_name off
set integrity for table_name foreign key immediate unchecked

And then you can do your inserts. To re-enable, you can then do the following:

set integrity for table_name immediate checked
Chris
A: 

You can do:

ALTER TABLE <table-name> ALTER FOREIGN KEY <constraint-name> NOT ENFORCED

and then to re-enable:

ALTER TABLE <table-name> ALTER FOREIGN KEY <constraint-name> ENFORCED

http://publib.boulder.ibm.com/infocenter/mptoolic/v1r0/index.jsp?topic=/com.ibm.db2tools.ama.doc.ug/amacric0.htm

brianegge