0
I am wanting to create two foreign keys through Mysql Workbench and when I apply the information it executes the code below:
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;
However, follow the error below:
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
I tried to find some solution, but nothing came up. What to do?
The problem is not that comma on line 2?
– Maycon F. Castro
It also has two dots and commas on lines 3 and 4
– Patrick Perdigão
No, the error continues.
– Pedro Schimmelpfeng
I was able to resolve by removing the VISIBLE terms on lines 2 and 3.
– Pedro Schimmelpfeng