Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to enable / disable constraints in db2 v7?

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.

like image 431
user52017 Avatar asked Jan 07 '09 18:01

user52017


1 Answers

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

like image 156
brianegge Avatar answered Oct 03 '22 03:10

brianegge