Usually there are two related tables, and we will carry out primary and foreign key constraints. But sometimes we may need to remove the primary and foreign key constraints. Below I will tell you how to remove the primary and foreign key constraints.
note is a table with foreign key constraints
show create table note;
After execution, the code similar to the following will appear,
Note_ibfk_1 and
note_ibfk_2 here are the foreign key names of constraints.
CONSTRAINT `note_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`), CONSTRAINT `note_ibfk_2` FOREIGN KEY (`ncid`) REFERENCES `noteclassification` (`ncid`)
Execute the following code, the foreign key is released successfully. (my table name is note)
alter table note drop foreign key note_ibfk_2;