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

voj3qocg  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(520)

我试图在workbench中向前设计一个er图来创建我的模式,但我得到了一个错误。我正在使用mysql workbench for mac。
这是我收到的错误信息:

  1. Executing SQL script in server
  2. 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 '
  3. INDEX `city_id_fk_idx` (`city_id` ASC) VISIBLE,
  4. INDEX `county_id_idx` (`cou' at line 13
  5. SQL Code:
  6. -- -----------------------------------------------------
  7. -- Table `k00243666_property_bubble`.`addresses`
  8. -- -----------------------------------------------------
  9. CREATE TABLE IF NOT EXISTS `k00243666_property_bubble`.`addresses` (
  10. `address_id` INT NOT NULL AUTO_INCREMENT,
  11. `address1` VARCHAR(45) NULL,
  12. `address2` VARCHAR(45) NULL,
  13. `eircode` VARCHAR(7) NULL,
  14. `town_id` INT NULL,
  15. `city_id` INT NULL,
  16. `county_id` INT NULL,
  17. PRIMARY KEY (`address_id`),
  18. INDEX `town_id_fk_idx` (`town_id` ASC) VISIBLE,
  19. INDEX `city_id_fk_idx` (`city_id` ASC) VISIBLE,
  20. INDEX `county_id_idx` (`county_id` ASC) VISIBLE,
  21. CONSTRAINT `town_id_fk`
  22. FOREIGN KEY (`town_id`)
  23. REFERENCES `k00243666_property_bubble`.`town` (`town_id`)
  24. ON DELETE NO ACTION
  25. ON UPDATE CASCADE,
  26. CONSTRAINT `city_id_fk`
  27. FOREIGN KEY (`city_id`)
  28. REFERENCES `k00243666_property_bubble`.`city` (`city_id`)
  29. ON DELETE NO ACTION
  30. ON UPDATE CASCADE,
  31. CONSTRAINT `county_id`
  32. FOREIGN KEY (`county_id`)
  33. REFERENCES `k00243666_property_bubble`.`county` (`county_id`)
  34. ON DELETE NO ACTION
  35. ON UPDATE CASCADE)
  36. ENGINE = InnoDB
  37. SQL script execution finished: statements: 5 succeeded, 1 failed
  38. Fetching back view definitions in final form.
  39. Nothing to fetch

有人知道我为什么会犯这个错误吗?

jecbmhm3

jecbmhm31#

我猜你的mariadb版本不支持 VISIBLE 或者 INVISIBLE 应用于索引定义。在任何情况下,索引在默认情况下都应该是可见的,因此您甚至不需要指定 VISIBLE . 尝试使用以下语法:

  1. INDEX town_id_fk_idx (town_id),
  2. INDEX city_id_fk_idx (city_id),
  3. INDEX county_id_idx (county_id)

下面是一个链接,指向向mariadb发出的功能请求。似乎没有 INVISIBLE 关闭优化器索引的语法。但是,它提供了一种替代方案:

  1. ALTER TABLE addresses DISABLE KEYS;

这将使优化器看不到所有索引。

相关问题