我正在尝试在MySQL数据库中创建一个表,我不确定我的语法出错了。在我的查询中,它返回我使用ENUM的行中的1064错误。以下是我的查询的一部分:
CREATE TABLE General
(
pId varchar(30) NOT NULL UNIQUE,
Hometown varchar(30) NOT NULL,
Year char(2) NOT NULL ENUM("FR","SO","JR","SR")
Position varchar(2) NOT NULL ENUM("PG","SG","SF","PF","C"),
Season char(4) NOT NULL DEFAULT 2016,
Date_Of_Birth DATE NOT NULL,
CONSTRAINT PRIMARY KEY (pId));
答案 0 :(得分:2)
缺少逗号,枚举不需要类型,季节是字符串' 2016'并删除主键的约束
CREATE TABLE General
(
pId varchar(30) NOT NULL UNIQUE,
Hometown varchar(30) NOT NULL,
Year ENUM("FR","SO","JR","SR"), <---- here missing commma
Position ENUM("PG","SG","SF","PF","C"),
Season char(4) NOT NULL DEFAULT '2016',
Date_Of_Birth DATE NOT NULL,
PRIMARY KEY (pId)
);