These two queries should produce scripts to drop and re-create foreign keys.
Code:
SELECT
'ALTER TABLE schema.' || SUBSTR(TABNAME,1,50),
' DROP FOREIGN KEY ' || CONSTNAME || ';'
FROM
SYSCAT.REFERENCES
where
tabschema = 'schema'
;
SELECT
'ALTER TABLE schema.' || SUBSTR(TABNAME,1,50),
'ADD CONSTRAINT ' || CONSTNAME,
'FOREIGN KEY (' || substr(FK_COLNAMES,1,50) || ')',
'REFERENCES schema.' || SUBSTR(REFTABNAME,1,17),
' ON DELETE ' ||
case deleterule
when 'A' then 'NO ACTION'
when 'C' then 'CASCADE'
when 'N' then 'SET NULL'
when 'R' then 'RESTRICT'
end,
' ON UPDATE ' ||
case updaterule
when 'A' then 'NO ACTION'
when 'R' then 'RESTRICT'
end
FROM
SYSCAT.REFERENCES
where
tabschema = 'schema'
;