How to drop a foreign key if I have not named it during creation
create table abc(
id number(10),
foreign key (id) references tab(roll)
);
even
alter table abc drop foreign key mn_ibfk_1;
is not working for me. I am using Oracle 10g.
How to drop a foreign key if I have not named it during creation
create table abc(
id number(10),
foreign key (id) references tab(roll)
);
even
alter table abc drop foreign key mn_ibfk_1;
is not working for me. I am using Oracle 10g.
As you did not specify a constraint name, Oracle generated one for you (something like
SYS_034849548
).You need to find the constraint name in order to be able to drop it:
will display the constraint name. Then you can drop the constraint using:
(replace
<constraint_name>
with the name you retrieved using the SQL statement)Note that the syntax is
alter table ... drop constraint
. There is nodrop foreign key
.Try this
alter table mn drop constraint mn_ibfk_1;
to find out for sure the name of the constraint try this query