I need to change a Primary Key by adding a new Field in a table.
Unfortunatelly when I created the table I forget to set a name for the primary key
Now I need to drop the primary key to recreate it with more fields but I don't know the name of the primary key, and the statement
is not usable because I have more database file and the name of Primary keys is different per database file.ALTER TABLE MYTABLE DROP CONSTRAINT MYINTEG_000
I tried to execute statement like this on a TSQLProcessor
seems to work but, even if I don't have error messages, the primary key is not dropped.SET TERM !!;
EXECUTE BLOCK RETURNS (stmt VARCHAR(1000)) AS
BEGIN
FOR
SELECT 'ALTER TABLE MYTABLE DROP CONSTRAINT ' ||
rdb$constraint_name
from
rdb$relation_constraints
where
rdb$relation_name = "MYTABLE"
AND rDB$CONSTRAINT_TYPE = 'PRIMARY KEY'
into :stmt
DO begin suspend; execute statement :stmt; end
END!!
set term ; !!
How I can solve?
Thanks
Louis.