我想使用MySQL Workbench将外键添加到表中,并在应用该软件时执行以下代码:
ALTER TABLE `insect_db`.`usu_ins`
ADD INDEX `fk_id_ins_idx` (`id_ins` ASC) VISIBLE,
ADD INDEX `fk_id_cad_idx` (`id_cad` ASC) VISIBLE;
;
ALTER TABLE `insect_db`.`usu_ins`
ADD CONSTRAINT `fk_id_ins`
FOREIGN KEY (`id_ins`)
REFERENCES `insect_db`.`insects` (`entry_cod`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_id_cad`
FOREIGN KEY (`id_cad`)
REFERENCES `insect_db`.`cadastro` (`entry_cod`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
但是,出现以下错误:
Operation failed: There was an error while applying the SQL script to the database.
Executing:
ALTER TABLE `insect_db`.`usu_ins`
ADD INDEX `fk_id_ins_idx` (`id_ins` ASC) VISIBLE,
ADD INDEX `fk_id_cad_idx` (`id_cad` ASC) VISIBLE;
;
ALTER TABLE `insect_db`.`usu_ins`
ADD CONSTRAINT `fk_id_ins`
FOREIGN KEY (`id_ins`)
REFERENCES `insect_db`.`insects` (`entry_cod`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
ADD CONSTRAINT `fk_id_cad`
FOREIGN KEY (`id_cad`)
REFERENCES `insect_db`.`cadastro` (`entry_cod`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '
ADD INDEX `fk_id_cad_idx` (`id_cad` ASC) VISIBLE' at line 2
SQL Statement:
ALTER TABLE `insect_db`.`usu_ins`
ADD INDEX `fk_id_ins_idx` (`id_ins` ASC) VISIBLE,
ADD INDEX `fk_id_cad_idx` (`id_cad` ASC) VISIBLE
我已经尝试寻找解决方案,但到目前为止没有任何效果。我该怎么办?