SQL语句中的语法错误(如果不存在则创建表)

时间:2014-03-20 20:17:20

标签: mysql sql sqlite syntax

CREATE TABLE IF NOT EXISTS ax_storage 
(PID INT NOT NULL AUTO_INCREMENT, 
 PRIMARY KEY(PID), 
 Playername VARCHAR(32), 
 Time INT(10), Type INT(6), 
 World VARCHAR(32);

这个SQL语句出了什么问题?

2 个答案:

答案 0 :(得分:10)

您缺少在查询结尾处关闭括号

CREATE TABLE IF NOT EXISTS ax_storage 
(
    PID INT NOT NULL AUTO_INCREMENT, 
    PRIMARY KEY(PID), Playername VARCHAR(32), 
    Time INT(10), 
    Type INT(6), 
    World VARCHAR(32)
);  -- <- you were missing this one

答案 1 :(得分:2)

您在查询结束时忘记了)

  CREATE TABLE IF NOT EXISTS ax_storage (PID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(PID), Playername VARCHAR(32), Time INT(10), Type INT(6), World VARCHAR(32));