Subject RE: [firebird-support] How to drop a contstraint where I don't know the name
Author Brenden Walker
> -----Original Message-----
> From: firebird-support@yahoogroups.com
> [mailto:firebird-support@yahoogroups.com] On Behalf Of Martijn Tonies
> Sent: Wednesday, May 18, 2005 4:16 PM
> To: firebird-support@yahoogroups.com
> Subject: Re: [firebird-support] How to drop a contstraint
> where I don't know the name
>
>
> > I need to drop a constraint from a table. I know the tablename and
> > that the constraint is a foreign key to another table. But as the
> > constraint has no specific name, it can be called INTEG_xx....
> >
> > How can I now drop this constraint without knowing the
> name? I need to
> > do this by script on several databases.
> >
> > Thank you
> >
> > Herbert
> >
> >
> > ALTER TABLE CUSTOMERINFO DROP CONSTRAINT INTEG_87
>
> Without knowing the name, you cannot drop the constraint.
>
> With regards,

Well, not quite. You can:

delete from RDB$RELATION_CONSTRAINTS where RDB$RELATION_NAME = "<some
table name>" and RDB$CONSTRAINT_TYPE = "<some type>"

Of course this requires deletion of all constraints of a particular
type, but for this persons question it might be possible to use the
RDB$INDEX_NAME (pull the primary index from the foreign table perhaps?)