CREATE TABLE `DELIVERY` (
`del_ID` VARCHAR(45) NOT NULL,
`del_date` DATETIME NOT NULL,
`del_time` DATETIME NOT NULL,
`VEHICLE_veh_ID` INT NOT NULL,
`DRIVER_dr_ID` INT NOT NULL,
INDEX `fk_VEHICLE_has_DRIVER_DRIVER1_idx` (`DRIVER_dr_ID` ASC),
INDEX `fk_VEHICLE_has_DRIVER_VEHICLE1_idx` (`VEHICLE_veh_ID` ASC),
PRIMARY KEY (`del_ID`),
CONSTRAINT `fk_VEHICLE_has_DRIVER_VEHICLE1`
FOREIGN KEY (`VEHICLE_veh_ID`)
REFERENCES `ZionDB`.`VEHICLE` (`veh_ID`)
CONSTRAINT `fk_VEHICLE_has_DRIVER_DRIVER1`
FOREIGN KEY (`DRIVER_dr_ID`)
REFERENCES `ZionDB`.`DRIVER` (`dr_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以便在#CONS; CONSTRAINT
fk_VEHICLE_has_DRIVER_DRIVER1
附近使用正确的语法 外键(DRIVER_dr_ID
) '在第13行
我需要一只手,因为我不理解我的错误,而且我被卡住了。
答案 0 :(得分:0)
在第一次FK定义后忘记逗号。
正确的语法是
CREATE TABLE `DELIVERY` ( `del_ID` VARCHAR(45) NOT NULL, `del_date` DATETIME NOT NULL, `del_time` DATETIME NOT NULL, `VEHICLE_veh_ID` INT NOT NULL, `DRIVER_dr_ID` INT NOT NULL, INDEX `fk_VEHICLE_has_DRIVER_DRIVER1_idx` (`DRIVER_dr_ID` ASC), INDEX `fk_VEHICLE_has_DRIVER_VEHICLE1_idx` (`VEHICLE_veh_ID` ASC), PRIMARY KEY (`del_ID`), CONSTRAINT `fk_VEHICLE_has_DRIVER_VEHICLE1` FOREIGN KEY (`VEHICLE_veh_ID`) REFERENCES `ZionDB`.`VEHICLE` (`veh_ID`), CONSTRAINT `fk_VEHICLE_has_DRIVER_DRIVER1` FOREIGN KEY (`DRIVER_dr_ID`) REFERENCES `ZionDB`.`DRIVER` (`dr_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION);