How can I temporarily disable all constraints in a Table in Firebird 2.1?
Asked Answered
A

2

6

I want to disable all Foreign key constraints and re-enable them after, is there some way to do that?

I know that SQLServer allows that, but what about Firebird?

Aweather answered 30/6, 2009 at 13:13 Comment(0)
G
3

AFAICT foreign keys can't be disabled in Firebird up to 2.1.
You'd have to drop and recreate them.
There's a similar thread on Devshed.

Granddaughter answered 1/7, 2009 at 0:3 Comment(2)
+1. With a tool that shows the system tables one can see that there is no field in RDB$RELATION_CONSTRAINTS that would allow to disable foreign key constraints. Indexes OTOH can be made inactive, and RDB$INDICES has a field RDB$INDEX_INACTIVE.Maharani
Yes, but indexes that support constraints cannot me deactivated. Trying to do so results in an error.Granddaughter
D
0

I guess the only way is to drop and later re-create them. Since constraints are not data, you really do not lose any information from the database, so it is a harmless operation (provided that you keep the script to recreate them later).

Version of FlameRobin in SVN repository has an option to generate those DROP and CREATE scripts automatically for chosen table column dependencies. Last official release has the same option for entire tables, so that might help you. There is no option to do it for the whole database, though. Maybe some other admin. tool has that feature.

Dissent answered 3/5, 2010 at 10:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.