關於用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語句如下
1 drop table if exists tb_users; 2 3 /*==============================================================*/ 4 /* Table: tb_users */ 5 /*==============================================================*/ 6 create table tb_users 7 ( 8 userid national int not null auto_increment comment '用戶id', 9 orgid int comment '組織id', 10 username varchar(50) not null comment '姓名', 11 account varchar(50) comment '賬號', 12 password varchar(100) comment '密碼', 13 sex varchar(10) comment '性別', 14 phone varchar(100) comment '電話', 15 duties varchar(100) comment '崗位職務', 16 mail varchar(100) comment '郵箱', 17 personstatus char default '0' comment '人員狀態(0在職,1離職)', 18 accountstatus char default '0' comment '賬號狀態(0正常,1注銷)', 19 enabletime datetime comment '賬號登錄有效時間', 20 newaddtime datetime comment '新增時間', 21 updatetime datetime comment '更新時間', 22 operater varchar(36) comment '操作人', 23 lastloadtime datetime comment '最后登錄時間', 24 bz1 varchar(200) comment '備注1', 25 bz2 varchar(200) comment '備注2', 26 bz3 varchar(200) comment '備注3', 27 primary key (userid) 28 ); 29 30 alter table tb_users comment '用戶表'; 31 32 alter table tb_users add constraint FK_Reference_11 foreign key (orgid) 33 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 中設置如圖:把前面對號去掉就可以

