Error forward engineer SQL DB to phpmyadmin ERROR - mysql

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

Related

Error 1064 in MySQL trying Forward Engineering

I'm new to MySQL and when I tried to do the "Forward Engineer" I've encountered this error:
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 '
CONSTRAINT `fk_Vendite_Prodotti`
FOREIGN KEY (`Prodotti_idProdotti`)
' at line 11
SQL Code:
-- -----------------------------------------------------
-- Table `mydb`.`Vendite`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Vendite` (
`idVendite` INT NOT NULL,
`dataVendita` DATETIME NULL,
`qta` INT NULL,
`costo` FLOAT NULL,
`Prodotti_idProdotti` INT NOT NULL,
PRIMARY KEY (`idVendite`),
INDEX `fk_Vendite_Prodotti_idx` (`Prodotti_idProdotti` ASC) VISIBLE,
CONSTRAINT `fk_Vendite_Prodotti`
FOREIGN KEY (`Prodotti_idProdotti`)
REFERENCES `mydb`.`Prodotti` (`idProdotti`)
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
I know there are a lot of questions about this topic but I've seen that it's a very specific. Also being new to SQL I have no idea what the problem could be
As far as concerns, MariaDB does not support invisible indexes (only MySQL 8.0 supports that), so the error comes from the use of the VISIBLE keyword.
Since indexes are visible by default anyway, I would suggest just removing it:
CREATE TABLE IF NOT EXISTS `mydb`.`Vendite` (
`idVendite` INT NOT NULL,
`dataVendita` DATETIME NULL,
`qta` INT NULL,
`costo` FLOAT NULL,
`Prodotti_idProdotti` INT NOT NULL,
PRIMARY KEY (`idVendite`),
INDEX `fk_Vendite_Prodotti_idx` (`Prodotti_idProdotti`),
CONSTRAINT `fk_Vendite_Prodotti`
FOREIGN KEY (`Prodotti_idProdotti`)
REFERENCES `mydb`.`Prodotti` (`idProdotti`)
ON DELETE NO ACTION
ON UPDATE NO ACTION
) ENGINE = InnoDB

MySQL Workbench Executing Script on Server - Error #1064

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.

Forward Engineering MySQL Workbench Error 1064

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.

MySQL Workbench schema synchronization causing error 1064

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

Error 1064 in SQL script while exporting from MySql workbench

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) ...);