mysqlworkbench转发工程错误

rt4zxlrg  于 2021-06-20  发布在  Mysql
关注(0)|答案(3)|浏览(533)

我正在mysql workbench 8.0中处理一个模型,当我单击forwardengineering并尝试生成我得到的模型脚本时

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

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

bmvo0sr5

bmvo0sr51#

mysql工作台正在为mysql 8生成脚本(它支持新的不可见索引),而您可能没有。
您需要在 Model\Model Options\MySQL\Target MySQL Version 或者,在全球范围内 Edit\Preferences\Modelling\MySQL\Target MySQL Version .

3okqufwl

3okqufwl2#

我也遇到了同样的问题,使用version=8.0.17。
如果在“外键选项”部分中未选择任何操作,则在形成关系时会产生错误。确保选中了“sql生成中的跳过”(如果未选择任何操作)。

这应该能解决问题!

7eumitmz

7eumitmz3#

或者,您可以在mysql工作台gui上,编辑->首选项,然后建模->mysql并更改默认的目标mysql。

相关问题