Subject | Re: [firebird-support] Re: Drop primary key constraint with no name |
---|---|
Author | Helen Borrie |
Post date | 2005-11-14T00:56:39Z |
At 09:24 PM 13/11/2005 +0000, you wrote:
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.
./heLen
>-Sure, it will (potentially) be different from one restore to another, too,
> >
> > 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
> >
>
>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.
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.
./heLen