MySQL Workbench Error 1064 - mysql

everyone! I'm newbie to MySQL. I've created a new model using Workbench tools(I mean, that I haven't written any string of code by myself).
When trying to forward engineer it I get:
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 'COMMENT '')
ENGINE = InnoDB' at line 8
SQL Code:
-- -----------------------------------------------------
-- Table `university`.`CITY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `university`.`CITY` (
`ID_CITY` INT NOT NULL COMMENT '',
`CNAME` TEXT(15) NULL COMMENT '',
`POPULATION` INT NULL COMMENT '',
PRIMARY KEY (`ID_CITY`) COMMENT '')
ENGINE = InnoDB
SQL script execution finished: statements: 5 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
Moreover, when trying to forward engineer default Workbench model "sakila_full" i get the same thing:
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 'COMMENT '',
INDEX `idx_actor_last_name` (`last_name` ASC) COMMENT '')
ENGINE ' at line 9
SQL Code:
-- -----------------------------------------------------
-- Table `sakila`.`actor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sakila`.`actor` (
`actor_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '',
`first_name` VARCHAR(45) NOT NULL COMMENT '',
`last_name` VARCHAR(45) NOT NULL COMMENT '',
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
PRIMARY KEY (`actor_id`) COMMENT '',
INDEX `idx_actor_last_name` (`last_name` ASC) COMMENT '')
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
SQL script execution finished: statements: 5 succeeded, 1 failed
Fetching back view definitions in final form.
Could not get definition for sakila.customer_list from server
Could not get definition for sakila.film_list from server
Could not get definition for sakila.nicer_but_slower_film_list from server
Could not get definition for sakila.staff_list from server
Could not get definition for sakila.sales_by_store from server
Could not get definition for sakila.sales_by_film_category from server
Could not get definition for sakila.actor_info from server
7 views were read back.
Thanks in advance!

Well, the BIG probleme is that Mysql Workbench adds itself indexes comments that generate an error, when using "Forward Engineer" or "Synchronize Model"
This problem did not exist when I was using version 6.0.

It looks like you've taken the COMMENT strings a little too far. According to the MySQL CREATE TABLE syntax, a COMMENT attribute is only permitted on a column definition. That means it's invalid on the INDEX or PRIMARY KEY definitions you have listed near the end of your CREATE statements.
The COMMENT '' aren't necessary and can be omitted entirely, especially since you are leaving them blank. Otherwise, they would be used for a little bit of extra human-readable metadata on your column definitions.
To get this working with what you have, remove the COMMENT attributes from your index and primary key definitions.
CREATE TABLE IF NOT EXISTS `university`.`CITY` (
`ID_CITY` INT NOT NULL COMMENT '',
`CNAME` TEXT(15) NULL COMMENT '',
`POPULATION` INT NULL COMMENT '',
-- No COMMENT on PK
PRIMARY KEY (`ID_CITY`)
) ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `sakila`.`actor` (
`actor_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '',
`first_name` VARCHAR(45) NOT NULL COMMENT '',
`last_name` VARCHAR(45) NOT NULL COMMENT '',
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '',
-- No COMMENT on PK or INDEX
PRIMARY KEY (`actor_id`),
INDEX `idx_actor_last_name` (`last_name` ASC)
) ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
Or the whole thing without any blank COMMENTs:
CREATE TABLE IF NOT EXISTS `university`.`CITY` (
`ID_CITY` INT NOT NULL COMMENT 'A comment that is not blank!',
`CNAME` TEXT(15) NULL,
`POPULATION` INT NULL,
PRIMARY KEY (`ID_CITY`)
) ENGINE = InnoDB;
(Same for the other table)
MySQL is generally quite good at pointing you directly to the source of your syntax error with the error message:
check the manual that corresponds to your MySQL server version for the right syntax to use near 'COMMENT ''),
With the exception of errors occurring at the end of the statement, which get a little ambiguous, the right syntax to use near will show you exactly what's amiss. In the above case, the COMMENT '') should direct you to the only COMMENT attribute followed by a ), which was the one at PRIMARY KEY. From there, check the manual (linked above) for legal syntax in each segment of your statement.

Remove "VISIBLE" and "INVISIBLE" words from all INDEX

Related

Error 1064 when importing SQL generated from MySQL Workbench forward engineering

I am trying to import a schema into MySQL (MariaDB 10.1.36) and I am getting the above error. I also tried direct forward engineering in MySQL Workbench but the results are the same.
ERROR 1064 (42000): 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
Sample code that fails is:
CREATE TABLE IF NOT EXISTS `example`.`adhere` (
`adhere_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`description` VARCHAR(100) NOT NULL,
`id_uuid` VARCHAR(36) NULL,
PRIMARY KEY (`adhere_id`),
INDEX `ix_tmp_autoinc` (`adhere_id` ASC) VISIBLE)
ENGINE = InnoDB
AUTO_INCREMENT = 19
DEFAULT CHARACTER SET = latin1;
I tried changing the backticks into single quotes in vain, I later removed them to same result. The expectation is to have the table created so do the rest structured like so.
remove the VISIBLE word
DEMO
CREATE TABLE IF NOT EXISTS `example`.`adhere`
(
`adhere_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
`description` VARCHAR(100) NOT NULL,
`id_uuid` VARCHAR(36) NULL,
PRIMARY KEY (`adhere_id`),
INDEX `ix_tmp_autoinc` (`adhere_id` ASC)
)
Check that your version of mariadb supports invisible/visible indexes here https://mariadb.com/kb/en/library/invisible-columns/ and if not turn off the option in mysql workbench here https://dev.mysql.com/doc/workbench/en/wb-table-editor-indexes-tab.html

Generated SQL script from workbench doesn`t work on MariaDB server

I created a scheme in mysql workbench and exported this scheme into SQL code.
.
When I want to generate table user on my server I am getting error.
Script:
CREATE TABLE IF NOT EXISTS 'user' (
'id' INT NOT NULL AUTO_INCREMENT,
'registerDate' TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
'login' VARCHAR(255) NOT NULL,
'password' VARCHAR(255) NOT NULL,
'status' TINYINT NOT NULL,
'credits' INT NOT NULL DEFAULT 0,
PRIMARY KEY ('id'),
UNIQUE INDEX 'login_UNIQUE' ('login' ASC) VISIBLE)
ENGINE = InnoDB;
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 ''user' ( 'id' INT NOT NULL AUTO_INCREMENT, 'registerDate' TIMESTAMP NOT NU' at line 1
I dont understand where is an error? I didnt see anything wrong.
Version on server: 10.1.32-MariaDB

MySQL Workbench giving Error 1064

I'm toying around with MySQL Workbench, using its tools to create my database. When attempting to forward engineer the database, I keep getting this error.
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 '-01-01,
`PlateNum` CHAR(7) NOT NULL DEFAULT 'ABCDEFG',
`CellPhone` INT(10) U' at line 9
SQL Code:
-- -----------------------------------------------------
-- Table `MetalDelivery`.`Drivers`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `MetalDelivery`.`Drivers` (
`DriverID` INT NOT NULL AUTO_INCREMENT,
`FName` CHAR(12) NOT NULL DEFAULT 'First',
`LName` CHAR(12) NOT NULL DEFAULT 'Last',
`Sex` CHAR(1) NOT NULL DEFAULT 'M',
`DOB` DATE NOT NULL DEFAULT 1900-01-01,
`PlateNum` CHAR(7) NOT NULL DEFAULT 'ABCDEFG',
`CellPhone` INT(10) UNSIGNED NOT NULL DEFAULT 5550000000,
PRIMARY KEY (`DriverID`))
ENGINE = InnoDB
SQL script execution finished: statements: 6 succeeded, 1 failed
In the SQL script preview, it does show a semicolon after InnoDB
Any kind of date needs to be specified as if a string:
`DOB` DATE NOT NULL DEFAULT '1900-01-01'
It's also worth expanding this schema a little. Names are frequently over 12 letters long. VARCHAR(255) is a good default for "string" fields.
You may find that these defaults are a huge mistake. It's possible someone's actual last name is "Last" in which case it's like they're using a default, or they simply don't have a last name. NULL values serve a purpose, so embrace them.

Cannot create table in mysql workbench

I am trying to add a table to my schema in MySQL workbench and I keep getting an error.
Message Log:
Executing:
CREATE TABLE `TestVisual`.`arc` (
`arcid` INT NOT NULL DEFAULT 0 COMMENT '',
`name` VARCHAR(45) NULL DEFAULT '' COMMENT '',
PRIMARY KEY (`arcid`) COMMENT '');
Operation failed: There was an error while applying the SQL script to the database.
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 'COMMENT '')' at line 4
SQL Statement:
CREATE TABLE `TestVisual`.`arc` (
`arcid` INT NOT NULL DEFAULT 0 COMMENT '',
`name` VARCHAR(45) NULL DEFAULT '' COMMENT '',
PRIMARY KEY (`arcid`) COMMENT '')
I have tried to follow a tutorial but I still get the error. There are other tables already on this server and I am able to change their data along with add and delete columns. I am also on the root user.
Barmar answered it above in the comments. This server is using an older version of MySQL so there are not allowed to be COMMENT in the sql. Deleted them and it worked fine.

1064 SQL workbench forward engineer error

When i try to use the forward enginner function in sql workbench i get this error at the final step. Have any idea why?
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 ')
REFERENCES `mydb`.`Account` ()
ON DELETE NO ACTION
ON UPDATE NO AC' at line 13
SQL Code:
-- -----------------------------------------------------
-- Table `mydb`.`ContactDetail`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`ContactDetail` (
`ContactDetailId` INT NOT NULL AUTO_INCREMENT COMMENT '',
`AccountId` VARCHAR(45) NOT NULL COMMENT '',
`Name` VARCHAR(45) NOT NULL COMMENT '',
`FirstName` VARCHAR(45) NOT NULL COMMENT '',
`Sex` ENUM('male', 'female') NOT NULL COMMENT '',
PRIMARY KEY (`ContactDetailId`) COMMENT '',
UNIQUE INDEX `ContactDetailId_UNIQUE` (`ContactDetailId` ASC) COMMENT '',
CONSTRAINT `AccountId`
FOREIGN KEY ()
REFERENCES `mydb`.`Account` ()
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