#1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150)

后端 未结 7 1365
星月不相逢
星月不相逢 2020-12-12 14:34

So I am trying to add a primary key to one of the tables in my database. Right now it has a primary key like this:

PRIMARY KEY (user_id, round_number)
         


        
7条回答
  •  失恋的感觉
    2020-12-12 15:11

    If you are adding a foreign key and faced this error, it could be the value in the child table is not present in the parent table.

    Let's say for the column to which the foreign key has to be added has all values set to 0 and the value is not available in the table you are referencing it.

    You can set some value which is present in the parent table and then adding foreign key worked for me.

提交回复
热议问题