MySQL Workbench导出Model提示['ERROR 1064 (42000): You have an error in your SQL syntax....syntax to use near 'VISIBLE']

时间:2025-03-03 22:05:38
CREATE TABLE IF NOT EXISTS `pihealth`.`warning_events` (
`wid` INT NOT NULL AUTO_INCREMENT,
`wtime` DATETIME NOT NULL,
`wip` VARCHAR(20) NOT NULL,
`wtype` INT(5) NOT NULL,
`wdetails` VARCHAR(255) NULL,
PRIMARY KEY (`wid`),
UNIQUE INDEX `wid_UNIQUE` (`wid` ASC) VISIBLE)
ENGINE = InnoDB;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VISIBLE)
ENGINE = InnoDB' at line 8

!!!!注意:索引VISIBLE 在MySQL8之后才支持

我查看了自己的MySQL version

 mysql --version
mysql Ver 14.14 Distrib 5.7.21, for osx10.13 (x86_64) using EditLine wrapper

所以我的MySQL是不支持VISIBLE,把VISIBLE删除后在MySQL中执行则没有报错。

若要以后建表不产生VISIBLE:

MySQL Workbench->Preferences->Modeling->MySQL->Default Target MySQL Version:(这里填写自己的MySQL Version 5.7.21)