MySQL Forums
Forum List  »  MySQL Workbench

Syntax error in create table statement
Posted by: Anthony Aslangul
Date: February 13, 2017 06:18AM

Hello,

I have a weird error when i try to synchronize my model with the database.

The create table statement makes an error:

CREATE TABLE IF NOT EXISTS `barometres`.`brm_questions` (
`id` INT(10) UNIQUE UNSIGNED NOT NULL AUTO_INCREMENT,
`theme_id` INT(10) UNIQUE UNSIGNED NOT NULL,
`question_type_id` TINYINT(3) NOT NULL,
`type` TINYINT(1) NULL DEFAULT NULL,
`reference` TINYINT(1) NULL DEFAULT NULL,
`created_at` DATETIME NOT NULL,
`updated_at` DATETIME NULL DEFAULT NULL,
`deleted_at` DATETIME NULL DEFAULT NULL,
INDEX `fk_brm_questions_brm_themes1_idx` (`theme_id` ASC),
INDEX `fk_brm_questions_brn_questions-types1_idx` (`question_type_id` ASC),
PRIMARY KEY (`id`),
CONSTRAINT `fk_brm_questions_brm_themes1`
FOREIGN KEY (`theme_id`)
REFERENCES `barometres`.`brm_themes` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_brm_questions_brn_questions-types1`
FOREIGN KEY (`question_type_id`)
REFERENCES `barometres`.`brn_questions-types` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8

This is normal, the id column should not be marked as UNIQUE (since i didn't checked it in workbench), and the UNSIGNED should be before the UNIQUE anyway.

Because the UNSIGNED is after the UNIQUE, i got this error for each table in my model:

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 'UNSIGNED NOT NULL AUTO_INCREMENT,
`theme_id` INT(10) UNIQUE UNSIGNED NOT NULL,' at line 2

As you can see, the theme_id column is also marked as UNIQUE even if i didn't check it too.

All my tables have the same problem and i really don't know how to solve it without manually change all statements in notepad.

Do you have any idea why workbench has this behavior ? This is Workbench 6.3.9, and the same model do the same error on 6.3.6

Thank you very much for your help.

Anthony

Options: ReplyQuote


Subject
Views
Written By
Posted
Syntax error in create table statement
3094
February 13, 2017 06:18AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.