I’m trying to delete all foreign keys of a table. First I get all the names of those keys using meta.getExportedKeys(null, null, table); and rs.getString("FK_NAME").
But when I try to delete this key using:
ALTER TABLE tablename DROP CONSTRAINT fkname
it only works for some keys. Sometimes I’m getting:
ORA-02443: Cannot drop constraint - nonexistent constraint
But the foreign key is definitely there. What am I doing wrong?
Have you tried
instead?
You might have created the constraint in a case-sensitive way, in which case, you’ll need to put the constraint name in double quotes when you drop it. Here’s an example session in SQL*Plus:
SQL> create table test (a integer); Table created. SQL> alter table test add constraint "abcd" unique (a); Table altered. SQL> alter table test drop constraint abcd; alter table test drop constraint abcd * ERROR at line 1: ORA-02443: Cannot drop constraint - nonexistent constraint SQL> alter table test drop constraint "abcd"; Table altered. SQL>