I have a table whose primary key is used in several other tables and has several foreign keys to other tables.
CREATE TABLE location (
locationID INT NOT
Here's a way to drop foreign key constraint, it will work.
ALTER TABLE location
.location_id
DROP FOREIGN KEY location_ibfk_1
;
step1: show create table vendor_locations;
step2: ALTER TABLE vendor_locations drop foreign key vendor_locations_ibfk_1;
it worked for me.
Hey I followed some sequence above, and found some solution.
SHOW CREATE TABLE footable;
You will get FK Constrain Name like
ProjectsInfo_ibfk_1
Now you need to remove this constraints. by alter table commantd
alter table ProjectsInfo drop foreign key ProjectsInfo_ibfk_1;
Then drop the table column,
alter table ProjectsInfo drop column clientId;
As everyone said above, you can easily delete a FK. However, I just noticed that it can be necessary to drop the KEY itself at some point. If you have any error message to create another index like the last one, I mean with the same name, it would be useful dropping everything related to that index.
ALTER TABLE your_table_with_fk
drop FOREIGN KEY name_of_your_fk_from_show_create_table_command_result,
drop KEY the_same_name_as_above
Try this:
alter table Documents drop
FK__Documents__Custo__2A4B4B5E
You can not drop the foreign key column because it is being referenced from the table assignmentStuff
. So you should first drop the foreign key constraint assignmentStuff.assignmentIDX
.
A similar question has already been asked here. Check also here for more info.