0

我有以下转储:

CREATE TABLE  `testdata`.`carer` (
  `ID` bigint(20) NOT NULL auto_increment,
  `IS_DELETED` bit(1) default NULL,
  `name` varchar(255) default NULL,
  `account_id` bigint(20) NOT NULL,
  `patient_carer_id` bigint(20) NOT NULL,
  PRIMARY KEY  (`ID`),
  KEY `FK5A0E781D4C45C51` (`patient_carer_id`),
  KEY `FK5A0E7818BCEF0FB` (`account_id`),
  CONSTRAINT `FK5A0E781D4C45C51` FOREIGN KEY (`patient_carer_id`) REFERENCES `patients` (`ID`),
  CONSTRAINT `FK5A0E7818BCEF0FB` FOREIGN KEY (`account_ID`) REFERENCES `account` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8

但结果我看到以下内容:错误1061(42000):重复键名'FK5A0E7818BCEF0FB'

是的,键的名称和约束的名称是相同的。但是使用其他键我们没有任何问题。但是,如果我将 KEY 更改FK5A0E7818BCEF0FBFK5A0E7818BCEF0FB1,它将起作用。

有关更多信息,请转储另外两个表:

CREATE TABLE  `testdata`.`account` (
  `ID` bigint(20) NOT NULL auto_increment,
  `IS_DELETED` bit(1) default NULL,
  `name` varchar(255) NOT NULL,
  `template` varchar(255) default NULL,
  `logoCache` bigint(20) default NULL,
  `suspended` bit(1) default NULL,
  `contactPerson` varchar(255) default NULL,
  `contactPersonPosition` varchar(255) default NULL,
  `clearLogo` bit(1) default NULL,
  `scheduling_settings_id` bigint(20) default NULL,
  `billing_id` bigint(20) default NULL,
  `settingsId` bigint(20) default NULL,
  `geocodingProvider_ID` bigint(20) default NULL,
  `mapProvider_ID` bigint(20) default NULL,
  `salesChannel_ID` bigint(20) default NULL,
  `available_time_id` bigint(20) default NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `scheduling_settings_id` (`scheduling_settings_id`),
  UNIQUE KEY `billing_id` (`billing_id`),
  UNIQUE KEY `settingsId` (`settingsId`),
  KEY `FKB9D38A2DBF9BE64A` (`mapProvider_ID`),
  KEY `FKB9D38A2D64C6436C` (`billing_id`),
  KEY `FKB9D38A2DBAC9B04B` (`geocodingProvider_ID`),
  KEY `FKB9D38A2D641A10EA` (`available_time_id`),
  KEY `FKB9D38A2D7D7F6D28` (`settingsId`),
  KEY `FKB9D38A2D44D2DE01` (`scheduling_settings_id`),
  KEY `FKB9D38A2D9A025321` (`salesChannel_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8




CREATE TABLE  `testdata`.`patients` (
  `ID` bigint(20) NOT NULL auto_increment,
  `IS_DELETED` bit(1) default NULL,
  `gpName` varchar(255) default NULL,
  `title` varchar(255) default NULL,
  `firstName` varchar(255) NOT NULL,
  `lastName` varchar(255) NOT NULL,
  `nhsNumber` varchar(255) NOT NULL,
  `sex` varchar(255) default NULL,
  `dateOfBirth` datetime default NULL,
  `weight` varchar(255) default NULL,
  `notificationMethod` varchar(255) default NULL,
  `ethnicity_id` bigint(20) default NULL,
  `mobilityCode_ID` bigint(20) default NULL,
  `homeLocation_ID` bigint(20) default NULL,
  `account_id` bigint(20) NOT NULL,
  `original_patient_id` bigint(20) default NULL,
  PRIMARY KEY  (`ID`),
  KEY `FK49A9760E511FA9D3` (`ethnicity_id`),
  KEY `FK49A9760E8BCEF0FB` (`account_id`),
  KEY `FK49A9760EC7B193C1` (`mobilityCode_ID`),
  KEY `FK49A9760EC0EFD76E` (`homeLocation_ID`),
  KEY `FK49A9760ED05CD81` (`original_patient_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2434 DEFAULT CHARSET=utf8
4

1 回答 1

1

您遇到了 mysql 错误3993245307

代替

CONSTRAINT `FK5A0E7818BCEF0FB` FOREIGN KEY (`account_ID`) REFERENCES `account` (`ID`)

尝试

CONSTRAINT `FK5A0E7818BCEF0FB` FOREIGN KEY (`account_id`) REFERENCES `account` (`ID`)

注意大小写的变化account_id

于 2009-10-15T22:42:31.337 回答