setting the target database version for mysql workbench migration - mysql

I am running a migration from sql server to mariadb 10.0 and the generated code keeps failing due to a syntax error in the create table statements.
Specifcally it doesn't like the INDEX lines of the create table statements. And example of a statement it chokes on is
CREATE TABLE t1 (
`fk_manager` varchar(255),
INDEX `imgr` (`fk_manager` ASC) visible
);
This is the error I get
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 'INDEX
`imgr` (`fk_manager` ASC) visible)'
at line 3
If i remove the visible keyword the same command works, so I assume this is syntax valid on newer versions of mysql but not mine. Is there any way I can tell mysql workbench to exclude it?

In the top menu click Model > Model Options
In the dialogue that pops up, select MySQL on the left side
Change Target MySQL Version to 5.7

Related

Why select json data not working in the mariadb?

My query like this :
select `information`->'$."full_name"' as `homeroom`
from `classes`
If the query run in my database local, it works. No error
But if the query run in my database server, it does not works. There exist error like this :
#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 '>'$."full_name"' as `homeroom`
from `classes` LIMIT 0, 25' at line 1
If I run select version(),
My version database local : 8.0.15
My version database server : 10.0.38-MariaDB
Seems it does not work because my database server using mariadb
How can I solve this problem?
Update :
I using data type text to infomation field
JSON functions weren't added to MariaDB until version 10.2.3. If you can't upgrade you will have to process the data in your application. Note that even in versions that support JSON, they don't support the -> notation (reference) so you will have to rewrite the query as
JSON_EXTRACT(information, '$.full_name')

MySQL syntax error - dropping foreign key if exist

The following ALTER statement is working fine on my local (xamp), but on my server (Debian), I'm getting 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
'IF EXISTS `foreign_key1`' at line 1
This is the query:
ALTER TABLE `table` DROP FOREIGN KEY IF EXISTS `foreign_key1`;
How do I fix the error?
Sounds like your development environment is running MariaDB, and your server is running MySQL.
MySQL doesn't support the IF EXISTS in an ALTER TABLE statement.
That syntax is supported in MariaDB 10.0.
To confirm the version running in each environment, we could execute
SHOW VARIABLES LIKE 'version'
MariaDB https://mariadb.com/kb/en/mariadb/alter-table/
MySQL https://dev.mysql.com/doc/refman/5.7/en/alter-table.html
I don't know if this answers the question that was asked... "What is the explanation for the observed behavior?" (Was that the question?)

Is there a way to run multi-SQLs by RMySQL(dbExecute)?

I am using RMySQL to connect and manipulate MySQL.
Now I have a SQL like:
"drop table if exists t_tmp; create table t_tmp(name varchar(20));"
which works just fine in MySQL CLI.
But when I put these SQLs to RMySQL.dbExecute() exception throws:
"could not run statement: 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 'create table t_tmp(name varchar(20))' at line 1"
I am trying to run the 2 SQLs respectively, then they both work out OK.
Is there any way I can put the whole STRING(SQLs) and run it correctly in RMySQL?
Thanks!

MySql - unable to create new tables after changing my.ini (windows)

In order to be able to create tables with capital letters I had to modify the my.ini file in ProgramData\MySQL\MySQL Server 5.7, U added lower_case_table_names = 2 at the end of the file like it was suggested here, when I closed MySQL server and restarted it couldn't create any new tables, so I removed the line I added, restarted the server again, I keep having this error
Operation failed: There was an error while applying the SQL script to the database.
Executing:
CREATE TABLE `toys`.`new_table` (
);
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 ')' at line 2
SQL Statement:
CREATE TABLE `toys`.`new_table` (
)
You cannot create a table without columns - you need something between the brackets there. E.g.:
CREATE TABLE `toys`.`new_table` (
id INT -- just for example
);

SQL syntax error in MySQL unsing a cast(Partition as Signed)

I have to support an application on a MySQL server. I can´t change the source code so I can´t change the used syntax.
My problem is that I always get an syntax error like this:
Microsoft OLE DB Provider for ODBC Drivers [-2147217900]
[MySQL][ODBC 5.1 Driver][mysqld-5.6.26]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 'Partition as Signed)' at
line 1
I looked into the log file and found the problem in this line:
Select *
from XYZ
where `Type`='something'
and Client='{3DBEA33A-9F0A-4e86-8354-F652713EA458}'
order by Cast(Partition as Signed);
I always get this error when the "Cast(Partition as Signed)" appears.
Is there any way to configure the server to accept this syntax?
I´m using MySQL (x64) 5.6.26 with InnoDB.
Partition is reserved word.
http://dev.mysql.com/doc/refman/5.6/en/keywords.html
you should use it with backticks
`Partition`