0

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?

Community
  • 1
  • 1
csc_csc
  • 11
  • 6
  • The error is in the exact point where MySQL reports it, right after `\`Cl_name\` VARCHAR`. You never set the column size! – Álvaro González Nov 28 '16 at 12:30
  • 1
    Defaulting to 'NULL' string instead of NULL... but why default to null at all then, by default NULL is the well default. also default to string '0' on a integer field just seems wrong. :P – xQbert Nov 28 '16 at 14:25
  • I did it like this because I though it would be an obligation to give this information when completing the database afterward, but for now it's empty. It's really difficult to find the correct way to do things, so many informations x) – csc_csc Nov 29 '16 at 07:39

1 Answers1

1

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',
Rahul
  • 76,197
  • 13
  • 71
  • 125