csc_csc
csc_csc

Reputation: 11

Mysql #1064 - syntax error on a varchar field

I just tried to create a new database based on a file.sql I generated on this :

http://ondras.zarovi.cz/sql/demo/?keyword=default

So I clicked on save, than generate sql, copied it in a notepad++, saved sql and then imported it on my phpmyadmin new Database. (Mysql 5.7)

So now here my problem, I got an 1064 error. I checked on internet, and all the answers I could find where about a date (timestamp) and for me it looks like it's one of the varchar.

Here's the error message :

#1064 - Erreur de syntaxe près de 'NOT NULL DEFAULT 'NULL',

  `Cl_forename` VARCHAR NOT NULL DEFAULT 'NULL',

  `C' à la ligne 4

And here is the first part of my file.sql

CREATE TABLE `Clients` (

  `id_client` INTEGER NULL AUTO_INCREMENT DEFAULT NULL,

  `Cl_num_member` SMALLINT NOT NULL DEFAULT '0',

  `Cl_name` VARCHAR NOT NULL DEFAULT 'NULL',

  `Cl_forename` VARCHAR NOT NULL DEFAULT 'NULL',

  `Cl_nickname` VARCHAR NOT NULL DEFAULT 'NULL',

  `Cl_geolocation` MEDIUMTEXT NULL DEFAULT NULL,

  `Cl_date_license_start` DATE NULL DEFAULT NULL,

  `Cl_date_license_stop` DATE NULL DEFAULT NULL,

  `Cl_special_requirement` MEDIUMTEXT NULL DEFAULT NULL,

This is just half of the first table. As you can see, one the few first lines you can see '' and then no '', I tested more than one possibility to see if one was a solution but I don't know which is best. (Or which one will actually work)

Any help would be appreciated..

EDIT :

I add value to all the varchar, text, int and date I had, and now I got this problem :

#1067 - default value invalide for 'Cl_num_member'

This is the line in the code :

`Cl_num_member` SMALLINT(11) NOT NULL DEFAULT NULL,

I saw on a website that for the int, you need to precise the (11) just to indicate it's number, but value is not important, is that right ? Because it looks like it's not.

Here the link for the post : What is the size of column of int(11) in mysql in bytes?

Upvotes: 0

Views: 2763

Answers (1)

Rahul
Rahul

Reputation: 77846

Problem is none of your varchar columns has size specified as per your posted code Cl_forename VARCHAR NOT NULL DEFAULT. This should rather be Cl_forename VARCHAR(100) NOT NULL DEFAULT

  `Cl_name` VARCHAR NOT NULL DEFAULT 'NULL',

  `Cl_forename` VARCHAR NOT NULL DEFAULT 'NULL',

  `Cl_nickname` VARCHAR NOT NULL DEFAULT 'NULL',

Upvotes: 1

Related Questions