在 mysql workbench 中正向工程 ER 图时出现错误 1064

Error 1064 when forward engineering a ER diagram in mysql workbench

我正在尝试在 Workbench 中转发 ER 图来创建我的模式,但我遇到了错误。我正在为 mac 使用 mySql Workbench。

这是我收到的错误消息:

 Executing SQL script in server
ERROR: 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 '
  INDEX `city_id_fk_idx` (`city_id` ASC) VISIBLE,
  INDEX `county_id_idx` (`cou' at line 13
SQL Code:
        -- -----------------------------------------------------
        -- Table `k00243666_property_bubble`.`addresses`
        -- -----------------------------------------------------
        CREATE TABLE IF NOT EXISTS `k00243666_property_bubble`.`addresses` (
          `address_id` INT NOT NULL AUTO_INCREMENT,
          `address1` VARCHAR(45) NULL,
          `address2` VARCHAR(45) NULL,
          `eircode` VARCHAR(7) NULL,
          `town_id` INT NULL,
          `city_id` INT NULL,
          `county_id` INT NULL,
          PRIMARY KEY (`address_id`),
          INDEX `town_id_fk_idx` (`town_id` ASC) VISIBLE,
          INDEX `city_id_fk_idx` (`city_id` ASC) VISIBLE,
          INDEX `county_id_idx` (`county_id` ASC) VISIBLE,
          CONSTRAINT `town_id_fk`
            FOREIGN KEY (`town_id`)
            REFERENCES `k00243666_property_bubble`.`town` (`town_id`)
            ON DELETE NO ACTION
            ON UPDATE CASCADE,
          CONSTRAINT `city_id_fk`
            FOREIGN KEY (`city_id`)
            REFERENCES `k00243666_property_bubble`.`city` (`city_id`)
            ON DELETE NO ACTION
            ON UPDATE CASCADE,
          CONSTRAINT `county_id`
            FOREIGN KEY (`county_id`)
            REFERENCES `k00243666_property_bubble`.`county` (`county_id`)
            ON DELETE NO ACTION
            ON UPDATE CASCADE)
        ENGINE = InnoDB

SQL script execution finished: statements: 5 succeeded, 1 failed

Fetching back view definitions in final form.
Nothing to fetch

有谁知道我为什么会收到这个错误?

我的猜测是您的 MariaDB 版本不支持应用于索引定义的 VISIBLEINVISIBLE。无论如何,默认情况下索引应该是可见的,因此您甚至不需要指定 VISIBLE。尝试使用此语法:

INDEX town_id_fk_idx (town_id),
INDEX city_id_fk_idx (city_id),
INDEX county_id_idx (county_id)

Here is a link 到 MariaDB 的功能请求。似乎没有 INVISIBLE 语法来关闭优化器的索引。但是,它提供了另一种选择:

ALTER TABLE addresses DISABLE KEYS;

这将使所有索引对优化器不可见。