MySQL “ERROR 1005 (HY000): Can't create table 'foo.#sql-12c_4' (errno: 150)”

后端 未结 14 802
情深已故
情深已故 2020-12-03 04:13

I was working on creating some tables in database foo, but every time I end up with errno 150 regarding the foreign key. Firstly, here\'s my code for creating t

14条回答
  •  萌比男神i
    2020-12-03 04:56

    check to make the field you are referencing to is an exact match with foreign key, in my case one was unsigned and the other was signed so i just changed them to match and this worked

    ALTER TABLE customer_information ADD CONSTRAINT fk_customer_information1 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE

提交回复
热议问题