I have had a 1 to many relationship between course and instructor, which I wanted to drop. When I tried to drop the instructorID in course table it told me that. I couldn\'t
Please run an SHOW CREATE TABLE course; to make sure instructorID is the name of foreign key constraint.
Additional: The error means MySQL searches for a foreign key constraint named "InstructorID" but there is no constraint with such name, maybe this is your column name, but you have to use the constraint name to delete foreign keys.
the reason why you cannot drop InstructorID is because you need to use the name of the constraint of the Foreign key . KevDev specified that you must run 'SHOW CREATE TABLE course' to find the constraint name. after doing so , you can delete the foreign key. BUT wait theres more, the 'key' still stays behind which must get deleted. You can run 'SHOW CREATE TABLE' course to check that the key is still behind. once checking that it is still there then perform what Bobby advised. 'Alter table drop key' in doing so you have fully removed the the foreign key
You need to delete the 'foreign key constraint' and the 'key'.
Alter Table <table name> drop foreign key <constraint_name>
Alter table <table name> drop key <column name>
After you run SHOW CREATE table course;
you should find the fk symbol which is commonly like the one bellow:
(course_ibfk_1)
it may differ according to your mysql version you are using then drop the foreign key using the fk symbol as follow :
alter table course drop foreign key course_ibfk_1;
Can't DROP 'string'; check that column/key exists: ALTER TABLE accreditor_architectures DROP string error show in terminal when remove column from data base in ruby on rails
To drop a FOREIGN KEY constraint:
MySQL:
ALTER TABLE Orders DROP FOREIGN KEY {Constraint/Key_name};
For SQL Server / Oracle / MS Access:
ALTER TABLE Orders DROP CONSTRAINT {Constraint/Key_name};