-1

table creation failed because a foreign key constraint was not correctly formed

the first create table my_seeking, works fine, when I try to run the create contactstoseeking I get the following err msg

Error Code: 1005. Can't create table 'db_ferguson.contactstoseeking' (errno: 150)

CREATE  TABLE IF NOT EXISTS `my_seeking` (
  `id` INT NOT NULL ,
  `seeking` VARCHAR(45) NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB
;

CREATE  TABLE IF NOT EXISTS `contactsTOseeking` (
  `id` INT NOT NULL ,
  `seek` VARCHAR(45) NOT NULL ,
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) ,
  UNIQUE INDEX `seek_UNIQUE` (`seek` ASC) ,
  CONSTRAINT `fk_contactsTOseeking_my_seeking1`
    FOREIGN KEY (`id` )
    REFERENCES `mydb`.`my_seeking` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

A search of the web shows that err 150 is tied to my fk constraint. Cannot create table. If the error message refers to error 150, table creation failed because a foreign key constraint was not correctly formed. If the error message refers to error –1, table creation probably failed because the table includes a column name that matched the name of an internal InnoDB table."

this code was generated BY MySQL, and this is my first attempt at foreign keys. I tried coding it manually and had issues so I thought that I would let workbench do it. WHAT EVER the problem is I cant see it or it is beyond my current skill set

4

1 回答 1

0

您是否尝试删除参考中的“mydb”文本?它表示“mydb”数据库中的一个表。

于 2013-11-08T23:27:26.543 回答