I've spent a few hours looking at the manual and need help now correcting the below erros. Thank you.
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 ''ACTION')
ENGINE = InnoDB' at line 17
SQL Code:
-- -----------------------------------------------------
-- Table `mydb`.`Patients`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Patients` (
`PatientKey` INT(11) NOT NULL,
`FirstName` VARCHAR(45) NULL,
`MiddleName` VARCHAR(45) NULL,
`LastName` VARCHAR(45) NULL,
`PhoneNumber` VARCHAR(20) NULL,
`doctors_DoctorKey` INT(11) NOT NULL,
PRIMARY KEY (`PatientKey`),
INDEX `fk_Patients_doctors1_idx` (`doctors_DoctorKey` ASC) VISIBLE,
CONSTRAINT `fk_Patients_doctors1`
FOREIGN KEY (`doctors_DoctorKey`)
REFERENCES `mydb`.`doctors` (`DoctorKey`)
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
What I'm working with:
Server type: MySQL
Server version: 8.0 - MySQL Community Server(GPL)
MySQL Workbench 8.0 CE
Remove the word VISIBLE......
Remove the word VISIBLE; it is not valid in the version you are running.
Related
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
before you say do some google i did for 1 and half hours straight and i still haven't found a fix for this issue please if you have any knowledge about this issue share your answers
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,
CONSTRAINT `fk_Doctors_department1`
FOREIGN KEY (`department_name' at line 10
SQL Code:
-- -----------------------------------------------------
-- Table `GPMS_DB`.`Doctors`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `GPMS_DB`.`Doctors` (
`id` INT NOT NULL,
`F_name` VARCHAR(45) NULL,
`L_name` VARCHAR(45) NULL,
`department_name` VARCHAR(20) NOT NULL,
PRIMARY KEY (`id`, `department_name`),
INDEX `fk_Doctors_department1_idx` (`department_name` ASC) VISIBLE,
CONSTRAINT `fk_Doctors_department1`
FOREIGN KEY (`department_name`)
REFERENCES `GPMS_DB`.`department` (`name`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
SQL script execution finished: statements: 8 succeeded, 1 failed
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
I have written an sql script with the following contents :
CREATE DATABASE IF NOT EXISTS stock_trading;
USE stock_trading;
CREATE TABLE IF NOT EXISTS transactions(
user_name VARCHAR(30) NOT NULL,
passwrd BINARY(64) NOT NULL,
balance_cash BIGINT NOT NULL DEFAULT 100000,
PRIMARY KEY (user_name,passwrd),
)ENGINE=InnoDB;
and every time I try to run it in the SQL command prompt it keeps giving away the error as:
ERROR 1064 (42000) at line 5 in file: 'db_script.sql': 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
the script appears to be correct but I don't know why it keeps giving this error.
Additional information:
Operating System : Arch Linux
Database : MariaDB
You have a stray comma at the end of your table definition:
PRIMARY KEY (user_name,passwrd),
^^^ remove this
Your full table definition:
CREATE TABLE IF NOT EXISTS transactions(
user_name VARCHAR(30) NOT NULL,
passwrd BINARY(64) NOT NULL,
balance_cash BIGINT NOT NULL DEFAULT 100000,
PRIMARY KEY (user_name, passwrd)
) ENGINE=InnoDB;
#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 ') VIRTUAL,
`title_type` VARCHAR(45) NULL DEFAULT null,
PRIMARY KEY (`id`))' at line 2
Here is a part of script:
CREATE TABLE IF NOT EXISTS `sggis`.`maps_type` (
`id` INT GENERATED ALWAYS AS () VIRTUAL,
`title_type` VARCHAR(45) NULL DEFAULT 'yandex',
PRIMARY KEY (`id`))
ENGINE = InnoDB;
SQL says that problem is in the 2nd line, but i can't find it.
Code generated by MySQL Workbench.
When using VIRTUAL columns you need to specify the expression
Any legal, deterministic expression which can be calculated is
permitted, with the following exceptions:
Your expression is blank.