我无法弄清楚我的桌子有什么问题..
CREATE TABLE PLAYER
(FirstName VARCHAR(15) NOT NULL,
LastName VARCHAR(15) NOT NULL,
BirthDate DATE,
Address VARCHAR(30),
EmailAddress VARCHAR(30) NOT NULL,
Sex CHAR,
TeamName VARCHAR(30) NOT NULL,
ClubName VARCHAR(30) NOT NULL,
AgeGroup VARCHAR(5) NOT NULL,
PRIMARY KEY (LastName),
FOREIGN KEY (TeamName)
**);**
CREATE TABLE TEAMS
(TeamName VARCHAR(30) NOT NULL,
AgeGroup VARCHAR(5) NOT NULL,
Sex CHAR,
CoachFName VARCHAR(20) NOT NULL,
CoachLName VARCHAR(20),
ClubName VARCHAR(30) NOT NULL,
PRIMARY KEY (TeamName),
FOREIGN KEY (AgeGroup)
**FOREIGN KEY (ClubName)**
);
以下是我一直收到的消息..老实说,我不知道如何让这个表执行!我用粗体突出显示消息说错误就在附近。
*Msg 102, Level 15, State 1, Line 13
Incorrect syntax near ')'.
Msg 156, Level 15, State 1, Line 24
Incorrect syntax near the keyword 'FOREIGN'.*
答案 0 :(得分:1)
您需要指定外键引用的表和字段。例如,对于第一个错误,您需要指定foreign key (teamname) references teams(teamname)
,如果这是您的意思。