建表语句报错误代码: 1064,near ‘)engine=innodb auto_increment=7 default charset=utf8‘ at line 8

建表语句报错误代码: 1064

原因是因为!
最后一个字段后面加了逗号!!
遇见一万次这个错了,还是会忘记,所以记录下来吧。

执行sql语句

CREATE TABLE t_order1(
  `id` BIGINT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `user_id` BIGINT(11) DEFAULT NULL COMMENT '用户id',
  `product_id` BIGINT(11) DEFAULT NULL COMMENT '产品id',
  `count` INT(11) DEFAULT NULL COMMENT '数量',
  `money` DECIMAL(11,0) DEFAULT NULL COMMENT '金额',
  `status` INT(1) DEFAULT NULL COMMENT '订单状态:0:创建中;1:已完结',
)ENGINE=INNODB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

报错

1 queries executed, 0 success, 1 errors, 0 warnings

查询:create table t_order1( `id` Bigint(11) Not null auto_increment primary key, `user_id` bigint(11) default null comment '用户id'...

错误代码: 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 ')engine=innodb auto_increment=7 default charset=utf8' at line 8

执行耗时   : 0 sec
传送时间   : 0 sec
总耗时      : 0 sec

删掉逗号执行

CREATE TABLE t_order1(
  `id` BIGINT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `user_id` BIGINT(11) DEFAULT NULL COMMENT '用户id',
  `product_id` BIGINT(11) DEFAULT NULL COMMENT '产品id',
  `count` INT(11) DEFAULT NULL COMMENT '数量',
  `money` DECIMAL(11,0) DEFAULT NULL COMMENT '金额',
  `status` INT(1) DEFAULT NULL COMMENT '订单状态:0:创建中;1:已完结'
)ENGINE=INNODB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

成功

1 queries executed, 1 success, 0 errors, 0 warnings

查询:create table t_order( `id` Bigint(11) Not null auto_increment primary key, `user_id` bigint(11) default null comment '用户id',...

共 0 行受到影响

执行耗时   : 0.024 sec
传送时间   : 1.002 sec
总耗时      : 1.027 sec
  • 7
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值