Subject Re: [firebird-support] Activate / Inactivate foreign keys?
Author Milan Babuskov
Sándor Tamás (HostWare Kft.) wrote:
> I wonder if ther is any possibility to turn foreign keys on / off, like a
> trigger, or something like this.

You can DROP them first, and ADD them later.

> It is because we have an archiver SP, which deletes dozens of records (if
> not thousands), and there are dependencies we have to manage.

There are ways for this. For example you could use FBCopy to get the
order of tables for deletion: just reverse the one it's using for
copying, and you'll have the correct order. Please note that it does not
support self-referencing tables though.

> So to make
> things simple, we delete foreign keys, then make that deletion. After that,
> we have to make a full database update to restore those foreign keys.

Full database update? What's that?

Running a bunch of ALTER TABLE ADD FOREIGN KEY statements should do the
job. It isn't much complicated to write a tool that would use the info
from system tables to drop all FKs and recreate them later. Which
programming language do you use to access Firebird?

Milan Babuskov