建表语句报错误代码: 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