El problema aquí es la diferencia en la sintaxis entre las diferentes versiones del servidor MySQL. Parece que MySQL Workbench 8.0.12 está generando automáticamente CREATE UNIQUE INDEX
declaración para el servidor MySQL versión 8.0 .
De los MySQL Server 8.0 Docs
, la sintaxis para CREATE INDEX
es:
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}
Sin embargo, esta opción de {VISIBLE | INVISIBLE}
no está disponible en MySQL Server 5.7 . Desde Documentos
:
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' /* No option of VISIBLE / INVISIBLE */
index_type:
USING {BTREE | HASH}
Si no está buscando actualizar a la última versión de MySQL; puede deshabilitar esta función de generación automática con VISIBLE / INVISIBLE
índice:
En MySQL Workbench:
Ir a:
Editar> Preferencias> Modelado> MySQL.
Luego, establezca la "Versión de MySQL de destino predeterminada" en 5.7
Mira la captura de pantalla a continuación: