Subject | Re: Drop primary key constraint with no name |
---|---|
Author | val_melamed |
Post date | 2005-11-13T21:24:33Z |
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
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.
wrote:
>drop
> At 09:39 AM 13/11/2005 +0000, you wrote:
> >Hi all,
> >
> >I need to drop the primary key constraint on a table which was
> >created something like this:
> >
> >CREATE TABLE NameValue (
> > Name VARCHAR(100) NOT NULL,
> > Value VARCHAR(100)
> >);
> >ALTER TABLE NameValue ADD PRIMARY KEY (Name);
> >
> >I.e. the constraint does not have name. What is the best way to
> >the constraint in a script? From reading a similar question inthis
> >group it looks likeof
> >
> >delete from
> > RDB$RELATION_CONSTRAINTS
> >where
> > RDB$CONSTRAINT_TYPE='PRIMARY KEY' and
> > RDB$RELATION_NAME='NameValue'
> >
> >should do the trick. Can someone please confirm this as a number
> >our customers will be affected.your own
>
> No, it's *never* a good idea to manipulate metadata by performing
> DML operations on the system tables. That's in the top 5 ways tocorrupt
> databases. *READ* them, don't change them!query
>
> The "no-name" constraints in fact do have unique names. You can
> RDB$Relation_Constraints with your search clause to find out whatthey are.
>I have to admit that I feel a little embaressed: I read the no-no-s
> select rdb$constraint_name from rdb$relation_constraints
> where
> RDB$CONSTRAINT_TYPE='PRIMARY KEY' and
> RDB$RELATION_NAME='NameValue'
>
> Then, when you know it, you can drop it.
>
> alter table Department
> drop constraint INTEG_13
>
> ./heLen
>
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.