我有这个SQL代码,在尝试创建外键时不断出错。我不知道我在做什么。
CREATE TABLE IF NOT EXISTS `myDatabaseOne`.`Teams` (
`idTeams` INT NOT NULL COMMENT ' ',
`Semester` VARCHAR(45) NOT NULL,
`Year` YEAR NOT NULL,
`Captain` INT(5) NOT NULL,
`Sport` INT NOT NULL,
PRIMARY KEY (`idTeams`),
INDEX `fk_Teams_Students_idx` (`Captain` ASC),
INDEX `fk_Teams_Sports1_idx` (`Sport` ASC),
CONSTRAINT `fk_Teams_Students`
FOREIGN KEY (`Captain`)
REFERENCES `myDatabaseOne`.`Students` (`idStudents`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Teams_Sports1`
FOREIGN KEY (`Sport`)
REFERENCES `myDatabaseOne`.`Sports` (`idSports`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)