On 06/11/15 16:15, Rik van Kekem [email protected] [firebird-support] wrote: > 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)
You can't inactivate a FK constraint: SQL> ALTER INDEX FK_FOO INACTIVE; unsuccessful metadata update -MODIFY RDB$INDICES failed -action cancelled by trigger (2) to preserve data integrity -Cannot deactivate index used by an integrity constraint Scott
