Navicat cannot add foreign key constraint or does not display after adding a foreign key

    First of all, we need to clarify that there are many reasons why foreign keys cannot be added, and I have encountered only one of them to share here. It would be great if it could help everyone.

  • Right click -> Design Table. Check what your database engine is, because the default engine of the table database I built is MyISAM, so after I add a foreign key, the foreign key I added will not be displayed in the foreign key column.
    write picture description here

  • Then we will change it to the one shown below, and then add the foreign key:

write picture description here


  • it will be successful

    write picture description here

If you still get an error that foreign keys cannot be added, there may be other reasons. For example, there is data in your data table, you can try to clear the data and try again.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326263681&siteId=291194637