On 06/11/15 16:15, Rik van Kekem r...@graficalc.nl [firebird-support] wrote:
> Scott Morgan bl...@blueyonder.co.uk [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

  • [firebird-support] ... Scott Morgan bl...@blueyonder.co.uk [firebird-support]
    • Re: [firebird-... Rik van Kekem r...@graficalc.nl [firebird-support]
      • Re: [fireb... Scott Morgan bl...@blueyonder.co.uk [firebird-support]
        • Re: [f... Rik van Kekem r...@graficalc.nl [firebird-support]
        • Re: [f... Rik van Kekem r...@graficalc.nl [firebird-support]
    • Re: [firebird-... Helen Borrie hele...@iinet.net.au [firebird-support]
      • Re: [fireb... Scott Morgan bl...@blueyonder.co.uk [firebird-support]

Reply via email to