Problem with making a database on base of EER - mysql

I want to make a database based on my EER, but if I use Forward Engineering it always throws the same error.
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 ') ENGINE = InnoDB' at line 8
SQL Code:
-- Table `gip`.`Groepen`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `gip`.`Groepen` (
`idGroepen` INT NOT NULL,
`Groepnaam` VARCHAR(45) NOT NULL,
PRIMARY KEY (`idGroepen`),
UNIQUE INDEX `Groepnaam_UNIQUE` (`Groepnaam` ASC) VISIBLE)
ENGINE = InnoDB
SQL script execution finished: statements: 6 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
Any idea how to fix this?

I think VISIBLE is added after MySQL server version > 8.0 and you are using less than that.
Moreover, according to https://bugs.mysql.com/bug.php?id=92269, VISIBLE is default value. You can remove it.

Related

MySQL vs MariaDB - ddl - setting default for time field

I've got table products, and want to add column with type time.
I've got statement as follows:
ALTER TABLE products ADD openTime1 TIME DEFAULT TIME(now());
it works on MariaDB, but it doesnt work on Mysql.
On mysql it produces Error -
[42000][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 '(now())' at line 1
Can someone tell me why? whats wrong here? I thought that this should be the same.
In MySQL the expression used in DEFAULT field attribute must be wrapped into the parenthesis:
ALTER TABLE products ADD openTime1 TIME DEFAULT (TIME(now()));
db<>fiddle here

Issue with MySQL Generated Columns

Hello I am trying to make a alter an exsisting table to add a Generated columns which is the count of all the rows in another table(It will be a like system so I am going to do all the matching and "WHERE" once I get this to work)
I am currently using this.
ALTER TABLE board ADD like_cnt INT GENERATED ALWAYS AS (COUNT(*) FROM likes) NOT NULL;
But it gives me this 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 'FROM likes) NOT NULL' at line 1
I am using WAMP and it has SQL version 5.7.24
Is this not possible or am I doing something wrong ?
There are limits in GENERATED COLUMNS notably 'Subqueries are not permitted'

MySQLWorkbench forward engineering error

I'm working on a model in MySql Workbench 8.0, when I click on forward engineering and try to generate the script of my model 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 'VISIBLE,
CONSTRAINT `fk_Compras_Personas`
FOREIGN KEY (`persona_id`)
R' at line 9
SQL Code:
-- -----------------------------------------------------
-- Table `bd_inventario2018_2`.`compras`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `bd_inventario2018_2`.`compras` (
`nmcompra` INT(11) NOT NULL,
`persona_id` INT(11) NOT NULL,
`fecompra` DATE NOT NULL,
PRIMARY KEY (`nmcompra`, `persona_id`),
INDEX `fk_Compras_Personas_idx` (`persona_id` ASC) VISIBLE,
CONSTRAINT `fk_Compras_Personas`
FOREIGN KEY (`persona_id`)
REFERENCES `bd_inventario2018_2`.`personas` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
SQL script execution finished: statements: 6 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
Or when i try to syncronize the model 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 'VISIBLE' at line 4
SQL Code:
ALTER TABLE `bd_inventario2018_2`.`productos`
ADD COLUMN `anchetas_id` INT(11) NOT NULL AFTER `psventa`,
ADD COLUMN `productoscol` VARCHAR(45) NOT NULL AFTER `anchetas_id`,
ADD INDEX `fk_productos_Anchetas1_idx` (`anchetas_id` ASC) VISIBLE
SQL script execution finished: statements: 3 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
Someone knows what's happening? This is an automatic process, I'm not overwritting anything,
Thanks
MySQL Workbench is generating the script for MySQL 8 (which supports the new invisible indexes), which you likely do not have.
You need to specify the MySQL version you are using, either in Model\Model Options\MySQL\Target MySQL Version or, globally, in Edit\Preferences\Modelling\MySQL\Target MySQL Version.
Alternatively, you can go on the MySQL Workbench GUI, Edit->Preferences then Modeling->Mysql and change the default target MySQL.
I had the same problem, using version = 8.0.17.
The error originates when a relationship is formed if No action is selected in the "Foreign Key Options" section. Ensure that the Skip in SQL generation is checked (When No action is selected).
This should solve the problem!

Sphider MySQL Tables

I'm trying to install Sphider to search my site and when I try to create the MySQL tables I am getting this error:
create table query_log (
query varchar(255),
time timestamp(14),
elapsed float(2),
results int,
key query_key(query)
) ENGINE = MYISAM;
MySQL said: Documentation
\#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 '(14),
elapsed float(2),
results int,
key query_key(query)
) ENGINE = MYI' at line 3
How do I get round this?
According to the Sphider forums, it looks like this is an issue with the TimeStamp field type, or at least the way it's used in this CREATE TABLE query. (http://www.sphider.eu/forum/read.php?2,8933). On that forum page it is suggested that you:
1) editing the admin/install.php file,
2) Changing line 139,
FROM:
time timestamp(14),
TO
time timestamp,
There is no such thing as a timestamp(14).
The code should just be:
time timestamp;
Remove the (14)
Where the heck did you get that from, that they wouldn't understand basic mysql syntax?

MySQL Timestamping

I have a table in an Amazon Web Service (AWS) Relation Database Service (RDS) and the table columns are "Memory", "Cores", "Speed" and "Insert_Timestamp" and I am trying to get the database to log each time a new row is added to this table. With this being said, I am running the following code Alter table Instace_Types ALTER COLUMN Insert_Timestamp SET DEFAULT CURRENT_TIMESTAMP. I am running into this error:
"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 'COLUMN Insert_Timestamp SET DEFAULT CURRENT_TIMESTAMP' at line 1"
any input would be greatly appreciated.
The second ALTER should be a CHANGE.
Alter table Instance_Types
CHANGE Insert_Timestamp
Insert_Timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP