Mysql错误150无法创建表

时间:2014-09-18 03:32:45

标签: mysql sql database mysql-workbench

在我的乐透ER图中设计了mysql workbench我使用了正向工程选项。但有些表没有产生。因此,当我使用带有数据库选项的同步模型时,我有这个错误..

在服务器

中执行SQL脚本
  

错误:错误1005:无法创建表格' lottery.order' (错误:150)

CREATE  TABLE IF NOT EXISTS `lottery`.`order` (
  `o_id` INT(11) NOT NULL AUTO_INCREMENT ,
  `lot_id` INT(11) NOT NULL ,
  `draw` INT(11) NOT NULL ,
  `inst_id` INT(11) NULL DEFAULT NULL ,
  `qty` INT(11) NOT NULL ,
  `bprice` DOUBLE NOT NULL ,
  `total` DOUBLE NOT NULL ,
  `profit` DOUBLE NOT NULL ,
  PRIMARY KEY (`o_id`, `lot_id`, `draw`) ,
  INDEX `fk_order_d_draw1` (`lot_id` ASC, `draw` ASC) ,
  INDEX `fk_order_inst1` (`inst_id` ASC) ,
  CONSTRAINT `fk_order_d_draw1`
    FOREIGN KEY (`lot_id` , `draw` )
    REFERENCES `lottery`.`lot_draw` (`lot_id` , `draw` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_order_inst1`
    FOREIGN KEY (`inst_id` )
    REFERENCES `lottery`.`inst` (`inst_id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_swedish_ci
  

SQL脚本执行完成:语句:3个成功,1个失败

我不知道在哪里看。请帮帮我..

第一版之后

在服务器

中执行SQL脚本
  

错误:错误1005:无法创建表格' lottery.order' (错误:150)

-- -----------------------------------------------------
-- Table `lottery`.`order`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `lottery`.`order` (
  `o_id` INT NOT NULL AUTO_INCREMENT ,
  `lot_id` INT NOT NULL ,
  `draw` INT NOT NULL ,
  `inst_id` INT NULL ,
  `qty` INT NOT NULL ,
  `bprice` DOUBLE NOT NULL ,
  `total` DOUBLE NOT NULL ,
  `profit` DOUBLE NOT NULL ,
  PRIMARY KEY (`o_id`, `lot_id`, `draw`) ,
  INDEX `fk_order_d_draw1` (`lot_id` ASC, `draw` ASC) ,
  INDEX `fk_order_inst1` (`inst_id` ASC) ,

    FOREIGN KEY (`lot_id` , `draw` )
    REFERENCES `lottery`.`lot_draw` (`lot_id` , `draw` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,

    FOREIGN KEY (`inst_id` )
    REFERENCES `lottery`.`inst` (`inst_id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
  

SQL脚本执行完成:语句:8成功,1失败

0 个答案:

没有答案