SQL syntax error 'Incorrect syntax near 'UNSIGNED'.' - mysql

I have mysql2, inquirer, and console.table installed. I seems to be getting multiple errors when trying to create a table within my schema file.I have tried to reinstall all my packages to no avail. I have yet to create the seeds file as I thought i could knock the schema out of the way first if that might be whats causing the problem. Multiple errors in Schema file

Related

Prisma - How to fix Migration file after invalid column data value, and migration failed

Updated a column and put in an incorrect value for the varchar length. This caused the migration file to fail and now it wants to reset the Database and wipe everything out.
Error: P3006
Migration `20221205190350_migration_name_here` failed to apply cleanly to the shadow database.
Error code: P3018
Error:
A migration failed to apply. New migrations cannot be applied before the error is
recovered from. Read more about how to resolve migration issues in a production
database: https://pris.ly/d/migrate-resolve
Migration name: 20221205190350_migration_name_here
Database error code: 1074
Database error:
Column length too big for column 'cardJson' (max = 16383); use BLOB or TEXT instead
Please check the query number 1 from the migration file.
That is not an option.
I tried following the documentation to rollback and fix the migration, but it still wants to reset everything.
prisma migrate resolve --rolled-back "20221205190350_migration_name_here"
Then I updated it to a correct value in the SQL migration file and the schema file and tried to run it but it says it has already been applied (so not sure what the purpose of rolling it back then is?)
I need a way to adjust this migration file so the DB doesn't get reset. The table itself is empty so that could be dropped if that would help but I do not think any migrations are going to run unless I can find a way to fix this file.

how to get precise locations of syntax errors in a .sql script?

I'm trying to execute a .sql script which inserts values into a database.
Problem is, there's some issues in the syntax of the script.
Error Code: 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 1 0.078 sec
But the script is pretty large, a few Mos, so I can't check manually where the error is. According to the error message it should be close to quotes, but sadly all the values inserted are on one line in the script file so the indication "on line 1" is not helpful at all.
Is there a way to get a precise position for the error ? I'd like, in particular, the column number where the syntax is wrong. Is that possible ?
I'm using command of the type :
mysql -u root -p Wikicategory < path\to\script\script.sql
MySQL Workbench uses a different parser (ANTLR4 based) than the MySQL server (yacc based). ANTLR4 based parsers often (but not always) can report errors with a precise location.
I don't think the query is too large. If it were you would get a different error (because the connection buffer would not be large enough).
So, you best option is to reformat the query. For SELECTs you can use MySQL Workbench, but better try Visual Studio Code with the SQLTools plugin. Not the best results there either, but it seems to be able to reformat all types of queries.
Then run the script again to see if you get a better error location.

MySQL Workbench Syntax error 1064 when creating table

I am completely new to both SQL and MySQL, and I've created a Schema and want to make a table. I've specified all my fields, but I find that every time it generates code, it is incorrect. This happened when I previously tried to make my schema, but I was able to fix it. However, this time around I'm completely lost.
Here's my visual layout, the generated code, then the error log:

Importing SQL database to live server, tables missing

Okay, so first of all, I am SO sorry if this is an ignorant and stupid question. I have absolutely no knowledge of databases. I have only used them when creating and uploading Wordpress sites, and it works if everything goes without any errors.
So here is my problem:
I've created a Wordpress website on a local server. I've done the usual, exported the database, tried to upload it on the live server, but there seems to be an error.
I get the #1064 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 '?' at line 59
Half of the tables do not import on the live server. Here's what I've already tried:
Exporting the tables with the "Enclose export in a transaction" and "Disable foreign key checks" checked.
Exporting in two files with and without the mentioned options checked. This way I got more tables, and the wp_options table got
full instead of empty, but still only 15 tables instead of 23.
I checked to see if the "TYPE" syntax is "ENGINE" and it seems fine to my unknowing eyes.
I am a total ignorant when databases are concerned. I don't know what to check anymore. My guess is that the live server uses MariaDB and it is somehow not compatible with the SQL I'm trying to upload.
I tried to see the line 59, but there is no "?" there, at least not where I'm looking at. It might be that I'm looking at the wrong place, the blond that I am.
Here's the code around the line 59 when database is opened in editor.
--
-- Table structure for table `wp_gg_folders`
--
CREATE TABLE `wp_gg_folders` (
`id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I tried to see the MariaDB's documentation and the possible way to deal with any incompatibility would be to update my MySQL. I have no idea how to do it.
Oh and btw. I already have a working website on this server but with an older version of Wordpress, so if it's an old SQL version, why is it working there?
This turned out to be long... sorry. And thanks in advance!
Edit: I discovered there is a problem with exporting. In the exported file, there are always last third of the tables missing. I have no idea why. Can I somehow get the tables/whole database manually, and not through PhpMyAdmin?
Okay guys and girls, I've found the solution.
The problem was not in any error, it was in exporting the database at the very beginning, therefore, importing showed different kinds of errors each time I tried to import the database.
The query, while exporting would abort the export causing only part of the tables to be exported. By changing the length of the query while doing the export, I solved the problem.
Instead of 50000, I wrote in 1047551.
Here's the article that helped me, with screenshots:
https://wpengine.com/support/exporting-database/

MYSQL to HSQLDB migration issue

I have an issue with HSQLDB, I have a MySql database that I'm dumping to an in memory HSQLDB i get the following error when I run the script: Error: unexpected token: ( which is on a create table script and the offending line is TINYINT(3)
if I remove the brackets and the number it works fine, this is a valid declaration on MYSQL and I have tried turning MYSQL compatibility on by changing my url to: jdbc:hsqldb:mem:dataSource;sql.syntax_mys=true but this still doesn't work. :(
just as additional info I'm using a Spring hibernate connection and using Liquibase to do the dumping from MySQL to HSQLDB and I'm running HSQLDB v2.3.2
SQL Syntax especially DDL is not very well portable between different databases. You will have to learn the correct syntax for create table in HSQLDB witch is somewhat different from MySQL.
You can not just export table definition from one flavor of database and import into another.
Would be great if this would be the case but SQL Standard is quite loose...
I assume you have a DDL-Script, you can add SET DATABASE SQL SYNTAX MYS TRUE; to the top of it, see also here (Table 13.29. MySQL Style Syntax).
You may use this only for tests though; if you want to fully migrate to HSQLDB, changing the scripts themselves is sure the long term solution.