An error occurred while creating a foreign key for MySQL.

Source: Internet
Author: User

Can't create table 'xxx. # sql-1130_1 '(errno: 150)

Cause: Check whether the two fields associated are of the same type.

Solution: Change the field type to consistent

 

Cannot add or update a child row: A foreign key constraint fails ('xxx '. '# sql-1130_1', constraint 'fk _ x1x2 'foreign key ('x1') References 'xx2 '('x2 '))

Cause: data exists in the table associated with the foreign key. The field value of the field used as the foreign key does not exist in the table to be associated, therefore, the foreign key Association of the record in the table cannot be updated.

Solution: delete data in the table that creates a foreign key association, or delete the data that does not exist in the table to be joined.

 

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.