search

Home  >  Q&A  >  body text

Error when importing database file #1215 - Cannot add foreign key constraint

SQL query:

CREATE TABLE `blog_article` ( `id` int(4) NOT NULL AUTO_INCREMENT COMMENT 'Blog post primary key', `title` varchar(200) NOT NULL COMMENT 'Blog post title', ` order` int(4) NOT NULL DEFAULT '0' COMMENT 'Sort', `content` text NOT NULL COMMENT 'Content', `cat_id` int(4) NOT NULL COMMENT 'Category', `recommend` int(4) NOT NULL DEFAULT '1' COMMENT 'Whether it is recommended', `title_url` varchar(200) NOT NULL COMMENT 'Blog post address', `create_time` int(10) NOT NULL COMMENT 'Creation time', `update_time` int(10) NOT NULL COMMENT 'Update time', PRIMARY KEY (`id`), KEY `cat_id` (`cat_id`), CONSTRAINT `blog_article_ibfk_1` FOREIGN KEY (`cat_id`) REFERENCES `blog_category` (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8MySQL returns: #1215 - Cannot add foreign key constraint

SilvanoSilvano1441 days ago1542

reply all(1)I'll reply

  • 1900

    19002020-12-08 09:52:15

    image.png

    The error will be reported in Baidu immediately. It should be due to different data types or constraints

    reply
    0
  • Cancelreply