MySQLWorkbench正向工程错误

时间:2018-08-15 12:34:13

标签: mysql mysql-workbench sqlyog

当我单击正向工程并尝试生成所得到的模型脚本时,我正在MySql Workbench 8.0中处理模型。

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,
  CONSTRAINT `fk_Compras_Personas`
    FOREIGN KEY (`persona_id`)
    R' at line 9
SQL Code:
        -- -----------------------------------------------------
        -- Table `bd_inventario2018_2`.`compras`
        -- -----------------------------------------------------
        CREATE TABLE IF NOT EXISTS `bd_inventario2018_2`.`compras` (
          `nmcompra` INT(11) NOT NULL,
          `persona_id` INT(11) NOT NULL,
          `fecompra` DATE NOT NULL,
          PRIMARY KEY (`nmcompra`, `persona_id`),
          INDEX `fk_Compras_Personas_idx` (`persona_id` ASC) VISIBLE,
          CONSTRAINT `fk_Compras_Personas`
            FOREIGN KEY (`persona_id`)
            REFERENCES `bd_inventario2018_2`.`personas` (`id`)
            ON DELETE NO ACTION
            ON UPDATE NO ACTION)
        ENGINE = InnoDB
        DEFAULT CHARACTER SET = utf8

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

Fetching back view definitions in final form.
Nothing to fetch

或者当我尝试同步模型时得到

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' at line 4
SQL Code:
        ALTER TABLE `bd_inventario2018_2`.`productos` 
        ADD COLUMN `anchetas_id` INT(11) NOT NULL AFTER `psventa`,
        ADD COLUMN `productoscol` VARCHAR(45) NOT NULL AFTER `anchetas_id`,
        ADD INDEX `fk_productos_Anchetas1_idx` (`anchetas_id` ASC) VISIBLE

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

Fetching back view definitions in final form.
Nothing to fetch

有人知道发生了什么事吗?这是一个自动过程,我不会覆盖任何内容,

谢谢

3 个答案:

答案 0 :(得分:9)

MySQL Workbench正在为您可能没有的MySQL 8(支持新的不可见索引)生成脚本。

您需要在Model\Model Options\MySQL\Target MySQL Version或全局Edit\Preferences\Modelling\MySQL\Target MySQL Version中指定要使用的MySQL版本。

答案 1 :(得分:2)

或者,您可以转到MySQL Workbench GUI,依次单击“编辑”->“首选项”和“建模”->“ Mysql”,然后更改默认目标MySQL。

答案 2 :(得分:1)

使用版本= 8.0.17,我遇到了同样的问题。

如果在“外键选项”部分中未选择任何动作,则在形成关系时就会产生错误。确保选中“在SQL生成中跳过”(未选择任何操作时)。

enter image description here

这应该可以解决问题!