MySQL Workbench模式同步导致错误1064

时间:2018-09-07 20:37:26

标签: mysql syntax mysql-workbench

我正在使用MySQL Workbench尝试为数据库创建架构。当我尝试将其同步到服务器时,出现错误1064。这是完整的日志:

Executing SQL script in server
ERROR: Error 1064: 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,
  PRIMARY KEY (`id`),
  CONSTRAINT `buildings_rel`
    FOREIGN KEY (`bu' at line 10
SQL Code:
        CREATE TABLE IF NOT EXISTS `rentals`.`apartments` (
          `beds` INT(11) NOT NULL,
          `baths` INT(11) NOT NULL,
          `area` INT(11) NOT NULL,
          `price_min` INT(11) NOT NULL,
          `price_max` INT(11) NOT NULL,
          `available_now` BIT(1) NOT NULL,
          `building_id` INT(11) NULL DEFAULT NULL,
          `id` INT(11) NOT NULL AUTO_INCREMENT,
          INDEX `buildings_rel_idx` (`building_id` ASC) VISIBLE,
          PRIMARY KEY (`id`),
          CONSTRAINT `buildings_rel`
            FOREIGN KEY (`building_id`)
            REFERENCES `rentals`.`buildings` (`id`)
            ON DELETE NO ACTION
            ON UPDATE NO ACTION)
        ENGINE = InnoDB
        DEFAULT CHARACTER SET = utf8

我不太了解SQL,因此在弄清楚到底是什么错误时遇到了麻烦。我希望Workbench能够创建正确的代码,令我感到有些惊讶的是,这似乎是一个小问题。任何帮助表示赞赏,谢谢。

2 个答案:

答案 0 :(得分:1)

知道了!正如一些评论者所说,我必须在MySQL Workbench设置中设置不同的目标版本。谢谢!

答案 1 :(得分:0)

更改默认目标MySQL版本以匹配您的mysql版本。

Home -> Edit -> Preferences -> Modeling -> MySQL -> Default Target MySQL Version

enter image description here