无法创建表,错误号:150

时间:2010-12-13 12:33:06

标签: sql mysql maven mysql-error-1005

这些用于创建表的查询有什么不好?

CREATE  TABLE IF NOT EXISTS `CVM`.`CANDIDATE` (
  `ID` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `FULL_NAME` VARCHAR(64)  NOT NULL ,
  `HR_INTERVIEW_DATE` DATE NULL ,
  `JOB_SEARCH_STATUS` TINYINT(1)  NULL ,
  `REFERENCES_OPTIONAL` TEXT NULL ,
  `AVAILABILITY` TEXT NULL ,
  `LOCATION` VARCHAR(200) NULL ,
  `TRIP` TEXT NULL ,
  `INTERPERSONAL_RISKS` TEXT NULL ,
  `TECHNICAL_INTERVIEW_DATE` DATE NULL ,
  `EXPERIENCE_IT` TINYINT UNSIGNED NULL ,
  `EXPERIENCE_JAVA` TINYINT UNSIGNED NULL ,
  `ENGLISH_CHECK_DATE` DATE NULL ,
  `ENGLISH_READINESS_DIALOGUE` VARCHAR(100) NULL ,
  `ENGLISH_TIME_IMPROVMENT` TINYINT UNSIGNED NULL ,
  `ENGLISH_LEVEL_ID` INT NULL ,
  `LEVEL_ID` INT NULL ,
  `DESIRED_POSITIONS` VARCHAR(100) NULL ,
  `HR_COMMENT` TEXT NULL ,
  `EXPERT_COMMENT` TEXT NULL ,
  `FOREIGN_PASSPORT_ID` INT(11) UNSIGNED NULL ,
  `SALARY_ID` INT(11) UNSIGNED NULL ,
  `SSE_INFO_ID` INT(11) UNSIGNED NULL ,
  `EXPERT_NAME` VARCHAR(100) NULL ,
  `HR_NAME` VARCHAR(100) NULL ,
  `TEACHER_NAME` VARCHAR(100) NULL ,
  PRIMARY KEY (`ID`) ,
  INDEX `FK_CANDIDATE_ENGLISH_LEVEL1` (`ENGLISH_LEVEL_ID` ASC) ,
  INDEX `fk_CANDIDATE_LEVEL1` (`LEVEL_ID` ASC) ,
  INDEX `fk_CANDIDATE_FOREIGN_PASSPORT1` (`FOREIGN_PASSPORT_ID` ASC) ,
  INDEX `fk_CANDIDATE_SALARY1` (`SALARY_ID` ASC) ,
  INDEX `fk_CANDIDATE_SSE_INFO1` (`SSE_INFO_ID` ASC) ,
  CONSTRAINT `FK_CANDIDATE_ENGLISH_LEVEL1`
    FOREIGN KEY (`ENGLISH_LEVEL_ID` )
    REFERENCES `CVM`.`ENGLISH_LEVEL` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_CANDIDATE_LEVEL1`
    FOREIGN KEY (`LEVEL_ID` )
    REFERENCES `CVM`.`LEVEL` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_CANDIDATE_FOREIGN_PASSPORT1`
    FOREIGN KEY (`FOREIGN_PASSPORT_ID` )
    REFERENCES `CVM`.`FOREIGN_PASSPORT` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_CANDIDATE_SALARY1`
    FOREIGN KEY (`SALARY_ID` )
    REFERENCES `CVM`.`SALARY` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_CANDIDATE_SSE_INFO1`
    FOREIGN KEY (`SSE_INFO_ID` )
    REFERENCES `CVM`.`SSE_INFO` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `CVM`.`CANDIDATE_HISTORY`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `CVM`.`CANDIDATE_HISTORY` (
  `ID` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `CANDIDATE_ID` INT(11) UNSIGNED NOT NULL ,
  PRIMARY KEY (`ID`) ,
  INDEX `fk_CANDIDATE_HISTORY_CANDIDATE1` (`CANDIDATE_ID` ASC) ,
  CONSTRAINT `fk_CANDIDATE_HISTORY_CANDIDATE1`
    FOREIGN KEY (`CANDIDATE_ID` )
    REFERENCES `CVM`.`CANDIDATE` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `CVM`.`CANDIDATE_CHANGES`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `CVM`.`CANDIDATE_CHANGES` (
  `ID` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `FIELD` VARCHAR(100) NULL ,
  `CHANGED_VALUE` TEXT NULL ,
  PRIMARY KEY (`ID`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `CVM`.`CANDIDATE_HISTORY_has_CANDIDATE_CHANGES`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `CVM`.`CANDIDATE_HISTORY_has_CANDIDATE_CHANGES` (
  `CANDIDATE_HISTORY_ID` INT(11) UNSIGNED NOT NULL ,
  `CANDIDATE_CHANGES_ID` INT(11) UNSIGNED NOT NULL ,
  PRIMARY KEY (`CANDIDATE_HISTORY_ID`, `CANDIDATE_CHANGES_ID`) ,
  INDEX `fk_CANDIDATE_HISTORY_has_CANDIDATE_CHANGES_CANDIDATE_CHANGES1` (`CANDIDATE_CHANGES_ID` ASC) ,
  CONSTRAINT `fk_CANDIDATE_HISTORY_has_CANDIDATE_CHANGES_CANDIDATE_HISTORY1`
    FOREIGN KEY (`CANDIDATE_HISTORY_ID` )
    REFERENCES `CVM`.`CANDIDATE_HISTORY` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_CANDIDATE_HISTORY_has_CANDIDATE_CHANGES_CANDIDATE_CHANGES1`
    FOREIGN KEY (`CANDIDATE_CHANGES_ID` )
    REFERENCES `CVM`.`CANDIDATE_CHANGES` (`ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

在SQL工作台中一切正常,但是使用maven-sql-plugin它无法创建表candidate_history_has_candidate_changes。所有名称都少于64个符号。请帮忙!

3 个答案:

答案 0 :(得分:0)

尝试缩小可能的原因,从简单的create table开始。尝试使用和不使用反引号引用创建这个简单的表,以防插件没有正确处理它们。

检查您是否在两种情况下都以同一用户身份登录。

答案 1 :(得分:0)

查看表中是否有剩余物。如果表已经存在,则CREATE IF NOT EXIST不执行任何操作。 (有关详细信息,请参阅提问者的评论)。

答案 2 :(得分:0)