aspose file tools*
The moose likes JDBC and the fly likes Disabling constraints in DB2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Disabling constraints in DB2" Watch "Disabling constraints in DB2" New topic
Author

Disabling constraints in DB2

M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 388
I am making a JDBC-based application that generates sql scripts to migrate data between databases (even between db vendors). I have one for SQL2000, now I need one for DB2.

The schema has foreign key (FK) constraints, so the mass import needs to shut this off before calling sql insert statements.

In SQL2000, I use this command to disable FK constraints:
ALTER TABLE APPTABLENAME NOCHECK CONSTRAINT ALL;

This does not work in DB2. It does not like the "NOCHECK" part. Anyone know I can fix this?
[ January 06, 2006: Message edited by: M Burke ]
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Don't know for DB2. Probably your best source of info would be the DB2 documentation.

One thing that would be a more generic solution would be to drop the key and add it back upon completion.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Disabling constraints in DB2