表不是在数据库中创建的

时间:2017-04-10 19:09:20

标签: mysql database

我正在为我的项目创建一个数据库,命名为基金分配系统。当我尝试创建10-15表并在创建最后两个表时,外键约束未添加到表中并显示错误消息。

  

操作失败:应用SQL脚本时出错   数据库。执行:

ALTER TABLE `funddistribution`.`view` 
ADD INDEX `view_email_id_idx` (`view_email_id` ASC),
ADD INDEX `view_rep_id_idx` (`view_rep_id` ASC);
ALTER TABLE `funddistribution`.`view` 
ADD CONSTRAINT `view_email_id`
  FOREIGN KEY (`view_email_id`)
  REFERENCES `funddistribution`.`reg_off` (`reg_off_id`)
  ON DELETE CASCADE
  ON UPDATE CASCADE,
ADD CONSTRAINT `view_rep_id`
  FOREIGN KEY (`view_rep_id`)
  REFERENCES `funddistribution`.`report` (`report_id`)
  ON DELETE CASCADE
  ON UPDATE CASCADE;
     

错误1061:重复的密钥名称' view_email_id_idx' SQL语句:

ALTER TABLE `funddistribution`.`view` 
ADD INDEX `view_email_id_idx` (`view_email_id` ASC),
ADD INDEX `view_rep_id_idx` (`view_rep_id` ASC)

0 个答案:

没有答案