mysql add列 报错1064,MySQL#1064-varchar字段上的语法错误

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

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.

解决方案

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',

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值