Mysql创build表与自动递增身份证给错误

我只是无法find这个代码有什么问题…

connection.query('CREATE TABLE posts (postid int NOT NULL AUTO_INCREMENT, posttitle varchar(255) NOT NULL, postdate datetime NOT NULL, deleted boolean, ownerid int PRIMARY KEY (postid) )'); 

我得到错误

 Error: ER_PARSE_ERROR: 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 '(postid) )' at line 1 

我使用node和mysql npm模块。 请帮忙。

你忘记了,ownerid intPRIMARY KEY (postid) ,如下所示

 ownerid int PRIMARY KEY (postid) ^...Here 

你的CREATE TABLE语句应该是

 CREATE TABLE posts (postid int NOT NULL AUTO_INCREMENT, posttitle varchar(255) NOT NULL, postdate datetime NOT NULL, deleted boolean, ownerid int, //Add comma here PRIMARY KEY (postid));