Subject Re: [firebird-support] Re: Drop primary key constraint with no name
Author Helen Borrie
At 09:24 PM 13/11/2005 +0000, you wrote:
> >
> > select rdb$constraint_name from rdb$relation_constraints
> > where
> >
> > Then, when you know it, you can drop it.
> >
> > alter table Department
> > drop constraint INTEG_13
> >
> > ./heLen
> >
>I have to admit that I feel a little embaressed: I read the no-no-s
>but then I saw that post and thought it should be OK. Can you please
>help me how to do this right in a script - I saw at least two DB-s
>where the name of this constraint were different.

Sure, it will (potentially) be different from one restore to another, too,
never mind the differences between one customer's copy and another's.

Need I say that you shouldn't try to do this kind of messing about, e.g.
running scripts that drop constraints, when the database is on
line. However, you can write a stored procedure that takes the name of the
table as input, queries the system tables and writes a script as output
lines to an external table consisting simply of one char column that is
wide enough to take a statement, plus two bytes into which to write CRLF.

Also, don't overlook the fact that the engine won't let you drop any
constraints that other constraints depend on...your SP will have to find
those, too, output script statements to drop them first...commit....etc.