The problem here is the difference in syntax across different MySQL server versions. MySQL Workbench 8.0 is auto-generating CREATE UNIQUE INDEX
statement for the MySQL server version 8.0.
Most likely, your MySQL server version < 8.0. You can remove VISIBLE
keyword from your CREATE TABLE
statement. It will look as follows:
CREATE TABLE IF NOT EXISTS `mydb`.`Personal` (
`idPersonal` INT NOT NULL,
`Experience` INT NULL,
`Department_idDepartment` INT NOT NULL,
`Date_of_accept` DATE NOT NULL,
`Date_of_release` DATE NULL,
`Human_idMan` INT NOT NULL,
PRIMARY KEY (`idPersonal`),
INDEX `fk_Personal_Department1_idx` (`Department_idDepartment` ASC),
INDEX `fk_Personal_Human1_idx` (`Human_idMan` ASC),
CONSTRAINT `fk_Personal_Department1`
FOREIGN KEY (`Department_idDepartment`)
REFERENCES `mydb`.`Department` (`idDepartment`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Personal_Human1`
FOREIGN KEY (`Human_idMan`)
REFERENCES `mydb`.`Human` (`idMan`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
From the MySQL Server 8.0 Docs, the syntax for CREATE INDEX
is:
CREATE [UNIQUE | FULLTEXT | SPATIAL] INDEX index_name
[index_type]
ON tbl_name (key_part,...)
[index_option]
[algorithm_option | lock_option] ...
key_part: {col_name [(length)] | (expr)} [ASC | DESC]
index_option:
KEY_BLOCK_SIZE [=] value
| index_type
| WITH PARSER parser_name
| COMMENT 'string'
| {VISIBLE | INVISIBLE} -- Notice the option of VISIBLE / INVISIBLE
index_type:
USING {BTREE | HASH}
However, this option of {VISIBLE | INVISIBLE}
is not available in the MySQL Server 5.7. From Docs:
CREATE [UNIQUE | FULLTEXT | SPATIAL] INDEX index_name
[index_type]
ON tbl_name (key_part,...)
[index_option]
[algorithm_option | lock_option] ...
key_part:
col_name [(length)] [ASC | DESC]
index_option:
KEY_BLOCK_SIZE [=] value
| index_type
| WITH PARSER parser_name
| COMMENT 'string'
index_type:
USING {BTREE | HASH}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…