MySql 執行語句錯誤 Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to

關於用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

的解決辦法spa

 

sql語句以下 rest

 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;

執行後出現以下錯誤,code

[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

  解決辦法:server

是否發現執行的sql語句中多了個national關鍵字,把這個關鍵字去掉就能夠。blog

在podwer designer 中設置如圖:把前面對號去掉就能夠rem

相關文章
相關標籤/搜索