Mysqlerror: 150 error foreign key problem Mysql foreign key
BitsCN.com
Mysql error: 150 foreign key error
ERROR 1005 (HY000): Can't create table '*****. frm' (errno: 150)
Problem
1. make sure that the referenced tables and fields exist;
2. the fields that make up the foreign key must be indexed (the fields that make up the foreign key must be the primary key in other tables );
3. two or more tables associated with foreign keys must be INNODB tables;
4. The field type (description) should be the same
One of the SQL statements exported from workbench cannot be inserted into the database. you can leave it as a record.
Both Article 1 and Article 4 are clear. Mark Article 1 and Article 3.
2. this problem occurs when an index is required for this field. Previously, the field associated with the foreign key is changed to another one, which is the primary key, but is associated, that is, the union index is created, in this case, setting up a foreign key is not supported by mysql on this key. Therefore, you must create an index on this key separately.
3. INNODB supports foreign keys. MyISAM engine does not support foreign keys.
Therefore, we mainly look at these two types of errors. The table created with the tool usually does not have 1 or 4 errors, and we hope to help people who see the article reduce the waste of time. Make a record.
BitsCN.com