Bug #101270 Error 1064: create table with foreign key
Submitted: 22 Oct 2020 4:39 Modified: 28 Oct 2020 11:00
Reporter: Dung Nguyen Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench Severity:S7 (Test Cases)
Version:8.0.21 OS:Windows (Microsoft Windows 10 Pro)
Assigned to: CPU Architecture:Any
Tags: WBBugReporter

[22 Oct 2020 4:39] Dung Nguyen
Description:
----[For better reports, please attach the log file after submitting. You can find it in C:\Users\User\AppData\Roaming\MySQL\Workbench\log\wb.log]

11:34:47 [ERR][  GRTDispatcher]: exception in grt execute_task, continuing: Exception: There was an error while applying the SQL script to the database.
11:34:47 [ERR][  GRTDispatcher]: worker: task 'wizard task' has failed with error:.There was an error while applying the SQL script to the database.
11:34:53 [ERR][SQL Editor Form]: 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 '
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
  PRIMARY KEY (`id`),
  CONST...' at line 5
SQL Statement:
CREATE TABLE `employee`.`phone` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `phone_number` VARCHAR(45) NULL,
  `employee_id` INT NULL,
  INDEX `fk_phone_1_idx` (`employee_id` ASC) VISIBLE,
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
  PRIMARY KEY (`id`),
  CONSTRAINT `fk_phone_1`
    FOREIGN KEY (`employee_id`)
    REFERENCES `employee`.`employee` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8

How to repeat:
11:34:47 [ERR][  GRTDispatcher]: exception in grt execute_task, continuing: Exception: There was an error while applying the SQL script to the database.
11:34:47 [ERR][  GRTDispatcher]: worker: task 'wizard task' has failed with error:.There was an error while applying the SQL script to the database.
11:34:53 [ERR][SQL Editor Form]: 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 '
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
  PRIMARY KEY (`id`),
  CONST...' at line 5
SQL Statement:
CREATE TABLE `employee`.`phone` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `phone_number` VARCHAR(45) NULL,
  `employee_id` INT NULL,
  INDEX `fk_phone_1_idx` (`employee_id` ASC) VISIBLE,
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE,
  PRIMARY KEY (`id`),
  CONSTRAINT `fk_phone_1`
    FOREIGN KEY (`employee_id`)
    REFERENCES `employee`.`employee` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
[28 Oct 2020 11:00] MySQL Verification Team
Hello Dung Nguyen,

Thank you for the bug report.
Imho this is duplicate of Bug #95804, please see Bug #95804.

Regards,
Ashwini Patil
[5 Nov 2020 18:23] Brian Plunkett
Ashwini Patil, please note that this is not the same type of error.  MySQL does not support MariaDB databases (i.e. different database architecture & syntax from MySQL).  The ticket should be closed.
[6 Apr 2023 0:45] Diego de Paula Dhiego
CREATE TABLE FUNCIONARIO28 (
COD NUMBER(05)  NULL,
NOME VARCHAR(50)  NULL,
FUNCAO VARCHAR(40)  NULL,
COD SUP NUMBER(05),
ADMISSAO TIMESTAMP DEFAULT LOCALTIMESTAMP,
CONSTRAINT FUNC28_COD_FUN_PK PRIMARY KEY (COD_FUN),
CONSTRAINT FUNC28_COD_FUN_FK FOREIGN KEY (COD_SUP_FUN) 
REFERENCES FUNCIONARIO28 (COD_FUN));
[6 Apr 2023 0:48] Diego de Paula Dhiego
CREATE TABLE FUNCIONARIO28 (
COD_FUN NUMBER(05) NOT NULL,
NOME_FUN VARCHAR(50) NOT NULL,
FUNCAO_FUN VARCHAR(40) NOT NULL,
COD_SUP_FUN NUMBER(05),
ADMISSAO TIMESTAMP DEFAULT LOCALTIMESTAMP,
CONSTRAINT FUNC28_COD_FUN_PK PRIMARY KEY (COD_FUN),
CONSTRAINT FUNC28_COD_FUN_FK FOREIGN KEY (COD_SUP_FUN) 
REFERENCES FUNCIONARIO28 (COD_FUN));