Scott Morgan [email protected] [firebird-support] wrote: > In a FB2.5 system is there a way to temporarily disable foreign key > constraints? i.e. something like 'ALTER INDEX ... INACTIVE' Well, here is the way to activate indexes and foreign keys: How to activate all indexes? http://www.firebirdfaq.org/faq274/
So doing the reverse should work too: SET TERM !! ; EXECUTE BLOCK AS DECLARE VARIABLE stmt VARCHAR(1000); BEGIN for select 'ALTER INDEX '||rdb$index_name ||' INACTIVE;' from rdb$indices where (rdb$system_flag is null or rdb$system_flag = 0) order by rdb$foreign_key nulls last into :stmt do EXECUTE STATEMENT :stmt; END!! SET TERM ; !! (not tested) > Alternatively, how safe is dropping/recreating the FKs on the fly? If nobody is using the database, I see no harm (but I'm not an expert). If it's just an import of one table I would only deactivate the indexes/primary keys/foreign keys of that table (and foreign keys pointing to that table). (Could also be done with a EXECUTE BLOCK and select of the correct rows) (just don't forget to activate them again afterwards :)) Grtz, Rik
