Mysql error: 150 foreign key error

Source: Internet
Author: User

Mysql error: 150 foreign key ERROR error 1005 (HY000): Can't create table '****. frm' (errno: 150) www.2cto.com problem 1. Make sure 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. The two or more tables associated with foreign keys must be INNODB tables. 4. The same field type (description) is required. One of the SQL statements exported from workbench cannot be inserted into the database, you can make a record before. Both article 1 and article 4 are clear. Mark Article 1 and Article 3. Www.2cto.com 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.