MySQL cannot create foreign key constraint

后端 未结 12 2264
夕颜
夕颜 2020-12-08 12:39

I\'m having some problems creating a foreign key to an existing table in a mysql database.

I have the table exp:

+-------------+--------         


        
12条回答
  •  星月不相逢
    2020-12-08 13:25

    In some cases, I had to make the referenced field unique on top of defining it as the primary key.

    But I found that not defining it as unique doesn't create a problem in every case. I have not been able to figure out the scenarios though. Probably something to do with nullable definition.

提交回复
热议问题