I'm using MySQL Workbench to try to create a schema for my database. When I try to sync it up to the server, I'm getting an error 1064. Here's the full log:
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 'VISIBLE,
PRIMARY KEY (`id`),
CONSTRAINT `buildings_rel`
FOREIGN KEY (`bu' at line 10
SQL Code:
CREATE TABLE IF NOT EXISTS `rentals`.`apartments` (
`beds` INT(11) NOT NULL,
`baths` INT(11) NOT NULL,
`area` INT(11) NOT NULL,
`price_min` INT(11) NOT NULL,
`price_max` INT(11) NOT NULL,
`available_now` BIT(1) NOT NULL,
`building_id` INT(11) NULL DEFAULT NULL,
`id` INT(11) NOT NULL AUTO_INCREMENT,
INDEX `buildings_rel_idx` (`building_id` ASC) VISIBLE,
PRIMARY KEY (`id`),
CONSTRAINT `buildings_rel`
FOREIGN KEY (`building_id`)
REFERENCES `rentals`.`buildings` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
I don't really know SQL so I'm having trouble figuring out what exactly is wrong here. I expected the Workbench to create correct code, I'm a little surprised that it seems to be this glitchy. Any help appreciated, thank you.
Got it! As some of the commentors said, I had to set a different target version in the MySQL Workbench settings. Thanks!
Change the Default Target MySQL Version to match your mysql version.
Home -> Edit -> Preferences -> Modeling -> MySQL -> Default Target MySQL Version
Related
I am trying to create a table using MySQL workbench, but the error msg shows this error. Check online, it shows " often due to using reserved words, missing data in the database, or mistyped/obsolete commands. " But, I did not use any reserved words or missing data. So not sure why this error happens. Thanks!
Operation failed: There was an error while applying the SQL script to the database.
Executing:
CREATE TABLE `assign`.`users` (
`id` INT NOT NULL AUTO_INCREMENT,
`email` VARCHAR(128) NOT NULL,
`nickname` VARCHAR(255) NOT NULL,
`password` VARCHAR(128) NOT NULL,
`created_at` VARCHAR(45) NOT NULL DEFAULT 'CURRENT_TIMESTAMP()',
PRIMARY KEY (`id`),
UNIQUE INDEX `email_UNIQUE` (`email` ASC) VISIBLE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
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 ')
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8' at line 8
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
I made a EER diagram and I am trying to Forward Engineer it but I get this error and I can't find the mistake.
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 'INDEX
fk_User_Wallets1_idx (Wallets_idWallets ASC) VISIBLE, CONSTRAINT '
at line 13
SQL Code:
CREATE TABLE IF NOT EXISTS `mydb`.`User` (
`idUser` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NULL,
`email` VARCHAR(45) NULL,
`adress` VARCHAR(45) NULL,
`password` VARCHAR(45) NULL,
`saldo` INT NULL,
`date_start` DATETIME NULL,
`date_end` DATETIME NULL,
`Rolls_idRolls` INT NOT NULL,
`Wallets_idWallets` INT NOT NULL,
PRIMARY KEY (`idUser`, `Rolls_idRolls`, `Wallets_idWallets`),
INDEX `fk_User_Rolls1_idx` (`Rolls_idRolls` ASC) VISIBLE,
INDEX `fk_User_Wallets1_idx` (`Wallets_idWallets` ASC) VISIBLE,
CONSTRAINT `fk_User_Rolls1`
FOREIGN KEY (`Rolls_idRolls`)
REFERENCES `mydb`.`Rolls` (`idRolls`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_User_Wallets1`
FOREIGN KEY (`Wallets_idWallets`)
REFERENCES `mydb`.`Wallets` (`idWallets`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 11 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
This is mysql version issue Remove the VISIBLE. and run the code manually . Or update mysql server and the client into same version .
(Wallets_idWallets ASC) VISIBLE into (Wallets_idWallets ASC)
can you add engine
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Before you forward engineering tick the below options and continue the process,
Go to the option section > Under the set options for Database to be created
Skip creation of foreign keys
Skip creation of Indexes as well
generate separate create index statements
Generate Insert statement for table
And continue the forward engineering process.
Getting an error in the SQL script while exporting a model from MySQL workbench. Been looking around for a bit but can't find any answers that could help in this specific case.
Trying to export a script created in MySQL workbench to phpMyAdmin. Can anyone see what is wrong with this part of the script?
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 ')
REFERENCES mydb.Staff ()
ON DELETE NO ACTION
ON UPDATE NO ACTI' at line 15
SQL Code
-- -----------------------------------------------------
-- Table `mydb`.`course`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`course` (
`idcourse` INT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(45) NOT NULL,
`describtion` VARCHAR(45) NOT NULL,
`week start` DATE NOT NULL,
`week end` DATE NOT NULL,
`ECTS` INT NOT NULL,
`course responsible` VARCHAR(45) NOT NULL,
`level` VARCHAR(45) NOT NULL,
PRIMARY KEY (`idcourse`),
CONSTRAINT `course responsible`
FOREIGN KEY ()
REFERENCES `mydb`.`Staff` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `level`
FOREIGN KEY ()
REFERENCES `mydb`.`Level` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
Check the foreign key syntax
CREATE TABLE <table_name>(
column1 data_type[(size)] ,
column2 data_type[(size)] ,
constraint(constraint_name)
FOREIGN KEY [column1,column2...]
REFERENCES [primary_key_table] (column_list_of_primary_key_table) ...);
Please have a look in below SQL code
DROP TABLE IF EXISTS `xxx`.`reminder` ;
CREATE TABLE IF NOT EXISTS `xxx`.`reminder` (
`idreminder` INT NOT NULL AUTO_INCREMENT,
`patient_idpatient` INT NOT NULL,
`remind_about` TEXT NOT NULL,
`reminder_time` TIME NOT NULL,
`reminder_date` DATE NOT NULL,
`active` TINYINT(1) NOT NULL,
`repeat_action` TINYINT(1) NOT NULL,
`date_created` TIMESTAMP NULL,
`last_updated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`idreminder`),
INDEX `fk_Reminder_patient1_idx` (`patient_idpatient` ASC),
CONSTRAINT `fk_Reminder_patient1`
FOREIGN KEY (`patient_idpatient`)
REFERENCES `myglukose`.`patient` (`idpatient`)
ON DELETE CASCADE
ON UPDATE NO ACTION)
ENGINE = InnoDB;
When I copy this into PhpMyAdmin, I get the following 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 '`
I have 2 questions.
I really don't spot the error, what is it?
Important thing is that these auto generated SQL code from MySQL Work Bench!! All of these worked very well in Windows with XAMPP and all these issues are with Ubuntu running LAMP.Not only this error,in some tables I am also getting the error #1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
Why all of this with Ubuntu (14.04)? I installed LAMP by following this - http://devoncmather.com/setting-aws-ec2-instance-lamp-git/
How to fix this, if any issue with installation, any recommended alternate tutorial?