Question

I fighting with the most common error but failing to solve the issue.

DROP TABLE IF EXISTS `tvguide_db`.`tvchanel` ;

CREATE  TABLE IF NOT EXISTS `tvguide_db`.`tvchanel` (
  `idtvchanel` VARCHAR(16) NOT NULL ,
  `chanelname` VARCHAR(64) NOT NULL ,
  `icon` VARCHAR(30) NOT NULL ,
  `category` VARCHAR(32) NOT NULL ,
  `genre` VARCHAR(45) NULL ,
  `description` VARCHAR(256) NULL ,
  `chanellanguage` VARCHAR(3) NOT NULL ,
  PRIMARY KEY (`idtvchanel`) ,
  UNIQUE INDEX `idtvchanel_UNIQUE` (`idtvchanel` ASC) )
ENGINE = InnoDB;

DROP TABLE IF EXISTS `subscriber_db`.`chanellist_planid` ;

CREATE  TABLE IF NOT EXISTS `subscriber_db`.`chanellist_planid` (
  `chanelid` VARCHAR(16) NOT NULL ,
  PRIMARY KEY (`chanelid`) ,
  UNIQUE INDEX `chanelid_UNIQUE` (`chanelid` ASC) ,
  CONSTRAINT `fk_chanellist_planid_chanelid`
    FOREIGN KEY (`chanelid` )
    REFERENCES `tvguide_db`.`tvchanel` (`idtvchanel` )
    ON DELETE RESTRICT
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

I'am getting this error

ERROR 1005 (HY000): Can't create table 'subscriber_db.chanellist_planid' (errno: 150)

On this SHOW ENGINE INNODB STATUS; command gave me this.

131006  5:38:49 Error in foreign key constraint of table subscriber_db/chanellist_planid:

    FOREIGN KEY (`chanelid` )
    REFERENCES `tvguide_db`.`tvchanel` (`idtvchanel` )
    ON DELETE RESTRICT
    ON UPDATE NO ACTION)
ENGINE = InnoDB:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.
Note that the internal storage type of ENUM and SET changed in
tables created with >= InnoDB-4.1.12, and such columns in old tables
cannot be referenced by such columns in new tables.
See http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html
for correct foreign key definition.

Any solution. Thanks in Advance.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top