SQLSyntaxError创建表

时间:2016-02-12 11:33:24

标签: mysql syntax-error

创建SQL表时收到错误,我不确定原因。

CREATE TABLE 'Weights' {
ImageID int(3) AUTO_INCREMENT NOT NULL,
Weight1 double(15,13) NOT NULL,
Weight2 double(15,13) NOT NULL,                
Weight3 double(15,13) NOT NULL,
Weight4 double(15,13) NOT NULL,               
Weight5 double(15,13) NOT NULL,  
PRIMARY KEY(ImageID)
);
  

错误是:#1064 - 您的SQL语法出错;检查   手册,对应右边的MySQL服务器版本   语法在'' Weights'附近使用? {ImageID int(3)AUTO_INCREMENT NOT   NULL,Weight1 double(15,'在第1行

有人可以帮忙吗?

3 个答案:

答案 0 :(得分:1)

  • 不要将您的表名放在引号中。

  • 您使用{而不是(打开了。

    CREATE TABLE Weights (
    ImageID int(3) AUTO_INCREMENT NOT NULL,
    Weight1 double(15,13) NOT NULL,
    Weight2 double(15,13) NOT NULL,                
    Weight3 double(15,13) NOT NULL,
    Weight4 double(15,13) NOT NULL,               
    Weight5 double(15,13) NOT NULL,  
    PRIMARY KEY(ImageID)
    );
    

答案 1 :(得分:0)

试试这个:它是100%正常工作

CREATE TABLE 'Weights' (
ImageID int(3) AUTO_INCREMENT NOT NULL,
Weight1 double(15,13) NOT NULL,
Weight2 double(15,13) NOT NULL,                
Weight3 double(15,13) NOT NULL,
Weight4 double(15,13) NOT NULL,               
Weight5 double(15,13) NOT NULL,  
PRIMARY KEY(ImageID)
);

答案 2 :(得分:0)

你的波浪形大括号应该是一个括号

CREATE TABLE Weights (
ImageID int(3) AUTO_INCREMENT NOT NULL,
Weight1 double(15,13) NOT NULL,
Weight2 double(15,13) NOT NULL,                
Weight3 double(15,13) NOT NULL,
Weight4 double(15,13) NOT NULL,               
Weight5 double(15,13) NOT NULL,  
PRIMARY KEY(ImageID)
);

http://sqlfiddle.com/#!9/52123b2