MySql 执行语句错误 Err] 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

时间:2023-03-09 15:21:17
MySql  执行语句错误 Err] 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

关于用Power Designer 生成sql文件出现 错误  [Err] 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 'int not null auto_increment comment '用户id',

的解决办法

sql语句如下

 drop table if exists tb_users;

 /*==============================================================*/
/* Table: tb_users */
/*==============================================================*/
create table tb_users
(
userid national int not null auto_increment comment '用户id',
orgid int comment '组织id',
username varchar() not null comment '姓名',
account varchar() comment '账号',
password varchar() comment '密码',
sex varchar() comment '性别',
phone varchar() comment '电话',
duties varchar() comment '岗位职务',
mail varchar() comment '邮箱',
personstatus char default '' comment '人员状态(0在职,1离职)',
accountstatus char default '' comment '账号状态(0正常,1注销)',
enabletime datetime comment '账号登录有效时间',
newaddtime datetime comment '新增时间',
updatetime datetime comment '更新时间',
operater varchar() comment '操作人',
lastloadtime datetime comment '最后登录时间',
bz1 varchar() comment '备注1',
bz2 varchar() comment '备注2',
bz3 varchar() comment '备注3',
primary key (userid)
); alter table tb_users comment '用户表'; alter table tb_users add constraint FK_Reference_11 foreign key (orgid)
references tb_organize (orgid) on delete restrict on update restrict;

执行后出现如下错误,

[Err] 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 'int not null auto_increment comment '用户id',
orgid int com' at line 6

  解决办法:

是否发现执行的sql语句中多了个national关键字,把这个关键字去掉就可以。

在podwer designer 中设置如图:把前面对号去掉就可以

MySql  执行语句错误 Err] 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