Error importing: Operation has completed with errors

0

I'm trying to make a model's forward engineer to pass it to SQL and it throws a syntax error, the message says that it was completed with errors, the error as I said is syntax, but if the same workbench does the script, does it? why do you get it with errors?

This is the error:

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 '   CONSTRAINT fk_saldo_usuario
    FOREIGN KEY (usuario_cod_usuario)
    REF' at line 10 SQL Code:
        -- -----------------------------------------------------
        -- Table wallet.saldo
        -- -----------------------------------------------------
        CREATE TABLE IF NOT EXISTS wallet.saldo (
          cod_saldo INT NOT NULL AUTO_INCREMENT,
          saldo_meta VARCHAR(45) NULL,
          saldo_actual VARCHAR(45) NULL,
          usuario_cod_usuario INT NOT NULL,
          PRIMARY KEY (cod_saldo),
          INDEX fk_saldo_usuario_idx(usuario_cod_usuario ASC) VISIBLE,
          CONSTRAINT fk_saldo_usuari
            FOREIGN KEY (usuario_cod_usuario)
            REFERENCES wallet.usuario (cod_usuario)
            ON DELETE NO ACTION
            ON UPDATE NO ACTION)
        ENGINE = InnoDB

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

Fetching back view definitions in final form.
Nothing to fetch

Before, this did not happen to me, but lately it has happened to me.

    
asked by Esteban Calle 12.09.2018 в 14:43
source

2 answers

0

It seems that the index nomenclature is different.

the error occurs on line 10,

I have tried in SQLFiddle, and thus it seems that it removes the error:

I was reporting there:

  

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'

So I have removed the VISIBLE, since by default the indexes will be visible, and it seems to have advanced.

Can you try it?

CREATE TABLE IF NOT EXISTS wallet.saldo (
          cod_saldo INT NOT NULL AUTO_INCREMENT,
          saldo_meta VARCHAR(45) NULL,
          saldo_actual VARCHAR(45) NULL,
          usuario_cod_usuario INT NOT NULL,
          PRIMARY KEY (cod_saldo),
          INDEX 'fk_saldo_usuario_idx' (usuario_cod_usuario ASC) ,
          CONSTRAINT fk_saldo_usuario_idx
            REFERENCES wallet.usuario (cod_usuario)
            ON DELETE NO ACTION
            ON UPDATE NO ACTION)
        ENGINE = InnoDB
    
answered by 12.09.2018 / 15:49
source
1

The invisible indexes were added to MySQL 8.0, but your version of MariaDB (10.1.34) is equivalent in functionality to MySQL 5.7, so the visibility modifier of an index ( VISIBLE e INVISIBLE ) are not available on your MySQL server.

You must export the structure indicating compatibility with MySQL 5.7 or manually remove these modifiers both in the definition and in the relationships.

Also, the ASC or DESC modifiers in them do not really change the order until version 8.0 (although they are available for use since version 5.7), so you could also skip them:

Your query, without the modifiers that can give you problems, should be:

CREATE TABLE IF NOT EXISTS wallet.saldo (
  cod_saldo INT NOT NULL AUTO_INCREMENT,
  saldo_meta VARCHAR(45) NULL,
  saldo_actual VARCHAR(45) NULL,
  usuario_cod_usuario INT NOT NULL,
  PRIMARY KEY (cod_saldo),
  INDEX fk_saldo_usuario_idx(usuario_cod_usuario),
  CONSTRAINT fk_saldo_usuari
    FOREIGN KEY (usuario_cod_usuario)
    REFERENCES wallet.usuario (cod_usuario)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
) ENGINE = InnoDB;
    
answered by 12.09.2018 в 16:09