MySQL Forums
Forum List  »  MySQL Workbench

Error messages when trying to create table with foreign key
Posted by: Charles Iscove
Date: June 19, 2009 09:52AM

I have created a db structure in Workbench for my record collection and have exported the 'create table' code. Here are the first 2 tables. The second table won't import - I'm getting an errno: 150 error. Can you tell me what's causing it?

Thanks
Charles

-- -----------------------------------------------------
-- Table `mydb`.`Release`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Release` (
`idRelease` INT NOT NULL AUTO_INCREMENT ,
`Title` VARCHAR(45) NULL ,
`Artist` VARCHAR(45) NULL ,
`Format` VARCHAR(45) NULL ,
`Type` VARCHAR(45) NULL ,
`Issue` VARCHAR(45) NULL ,
`Country` VARCHAR(45) NULL ,
`Date` DATE NULL ,
`CatalogueNum` VARCHAR(45) NULL ,
`Company` VARCHAR(45) NULL ,
`Label` VARCHAR(45) NULL ,
`AudioFormat` VARCHAR(45) NULL ,
`Track` VARCHAR(45) NULL ,
`ChronologyNum` INT NULL ,
`LinerNotesBy` VARCHAR(45) NULL ,
`Notes` TEXT NULL ,
PRIMARY KEY (`idRelease`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Type`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `Type` (
`idType` INT NOT NULL AUTO_INCREMENT ,
`Type` VARCHAR(45) NULL ,
PRIMARY KEY (`idType`) ,
INDEX `fk_type` (`idType` ASC) ,
CONSTRAINT `fk_type`
FOREIGN KEY (`idType` )
REFERENCES `mydb`.`Release` (`Type` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;

Options: ReplyQuote


Subject
Views
Written By
Posted
Error messages when trying to create table with foreign key
2797
June 19, 2009 09:52AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.