MYSQ Add foreign key error: Check the manual, corresponds to your MySQL server version for the right syntax ' a T Line 1

Source: Internet
Author: User

Today, using NAVCAT to add foreign keys to a table error:

You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use-near ' Type=innodb ' on line 1

After troubleshooting, it was discovered that the types of the two tables were not the same:

Sql:show Table Status Query the state of the data table, engine that column is

To modify a table type using a statement: ALTER table ' cms_channel ' ENGINE = INNODB;

Problem solving

===============================================================

By the way, give the SQL statement that added the foreign key:

ALTER TABLE name add constraint fk_id foreign key (your foreign key field name) REFERENCES the outer table name (the primary key field name of the corresponding table);

Example:

ALTER TABLE cms_article add constraint fk_article_dept_1 foreign key (dept_id) REFERENCES sys_department (ID);

Use this statement to run without error, the client will also prompt the function to modify how many data, but re-query the database table structure when the changes are not successful, because the table type is not the same as the foreign key can not be established

MYSQ Add foreign key error: Check the manual, corresponds to your MySQL server version for the right syntax ' a T Line 1

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.