在JavaDB apache derby中我不知道是什么导致错误:语法错误:遇到“)”在第30行第1列.SQLState:42X01

时间:2013-04-22 23:54:08

标签: sql syntax-error derby javadb

CREATE TABLE "TravelerProfile" (
  "idTravelerProfile" int NOT NULL,
  "AccountID" int NOT NULL,
  "GivenName" varchar(45) DEFAULT NULL,
  "FamilyName" varchar(45) DEFAULT NULL,
  "Title" varchar(45) DEFAULT NULL,
  "Department" varchar(45) DEFAULT NULL,
  "Position" varchar(45) DEFAULT NULL,
  "TravelBooker" varchar(45) DEFAULT NULL,
  "IDnumber" varchar(10) DEFAULT NULL,
  "BusinessAddress" varchar(255) DEFAULT NULL,
  "BusinessPhone" varchar(12) DEFAULT NULL,
  "BusinessFax" varchar(12) DEFAULT NULL,
  "BusinessEmail" varchar(45) DEFAULT NULL,
  "HomeAddress" varchar(255) DEFAULT NULL,
  "HomePhone" varchar(12) DEFAULT NULL,
  "HomeEmail" varchar(45) DEFAULT NULL,
  "MobilePhone" varchar(12) DEFAULT NULL,
  "SpouseName" varchar(45) DEFAULT NULL,
  "SpouseContactNumber" varchar(45) DEFAULT NULL,
  "SpouseEmail" varchar(45) DEFAULT NULL,
  "DoctorsName" varchar(45) DEFAULT NULL,
  "DoctorsConctactNumber" varchar(45) DEFAULT NULL,
  "DoctorsEmail" varchar(45) DEFAULT NULL,
  "KnownMedicalConditions" varchar(512) DEFAULT NULL,
  "AttachmentID" varchar(45) DEFAULT NULL,
  "DateCreated" timestamp  DEFAULT NULL,
  "DateModified" timestamp  DEFAULT NULL,
  PRIMARY KEY ("idTravelerProfile"),
);

我一直收到这个错误。

Error: Syntax error: Encountered ")" at line 30, column 1.
SQLState:  42X01
ErrorCode: -1

2 个答案:

答案 0 :(得分:5)

因为您需要删除PRIMARY KEY之后的额外逗号

   "DateModified" timestamp  DEFAULT NULL,
   PRIMARY KEY ("idTravelerProfile"),       -- <<== remove this trailing comma
);

答案 1 :(得分:0)

  PRIMARY KEY ("idTravelerProfile"),
);

问题在于最后一行。在最终,删除之前,它不应该);为我修复此错误。

2小时后。