简体   繁体   中英

Linux can`t create table in mysql workbench

I`ve installed my sql workbecnh on linux:

MySqlWorkbench version

Using export -> forward engineer get this test script:

-- MySQL Script generated by MySQL Workbench
-- Sat 06 Feb 2021 01:14:50 PM EET
-- Model: New Model    Version: 1.0
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
USE `mydb` ;

-- -----------------------------------------------------
-- Table `mydb`.`test`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`test` (
  `idtest` INT NOT NULL,
  `testcoltes` VARCHAR(45) NULL,
  PRIMARY KEY (`idtest`),
  UNIQUE INDEX `idtest_UNIQUE` (`idtest` ASC) VISIBLE)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

And got this error:

CREATE TABLE IF NOT EXISTS `mydb`.`test` (   `idtest` INT NOT NULL,   `testcoltes` VARCHAR(45) NULL,   PRIMARY KEY (`idtest`),   UNIQUE INDEX `idtest_UNIQUE` (`idtest` ASC) VISIBLE) ENGINE = InnoDB   Error Code: 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 ') ENGINE = InnoDB' at line 5 0,00027 sec

it has created db, but unable to create any table. I wasn`t even participating in creating this script (it was just exported out of the model) so why am I getting this error?

You are missing a closing bracket:

UNIQUE INDEX `idtest_UNIQUE` (`idtest` ASC) VISIBLE) ENGINE = InnoDB;

Should be:

UNIQUE INDEX (`idtest_UNIQUE` (`idtest` ASC) VISIBLE) ENGINE = InnoDB;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM