Error while creating foreign key, error code: 1005 Can't create table 'test_message.#sql-dd0_4' (errno: 150)

I looked it up online and found four reasons:

1. The reference types of foreign keys are different. The primary key is int and the foreign key is char 
. 2. The column referenced in the main table cannot be found. 
3. The character encoding of the primary key and the foreign key is inconsistent 
. Build an index. There is also an error without indexing

Then I looked at my database and found that the error was because the foreign key associated with the slave table was not the primary key.

Guess you like

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