我有点困惑,我的遗失左括号正在发挥作用(ORA-00906:缺少左括号)。有什么建议?下面是一个具有明显测试名称的类似语法的示例。谢谢你的任何建议!
CREATE TABLE rosters (
rosterid NUMBER(5) PRIMARY KEY,
playerid NUMBER(5) NOT NULL,
teamid NUMBER(5) NOT NULL,
seasonid NUMBER(5) NOT NULL,
CONSTRAINT fk_player FOREIGN KEY playerid REFERENCES players(playerid),
CONSTRAINT fk_team FOREIGN KEY teamid REFERENCES teams(teamid),
CONSTRAINT fk_season FOREIGN KEY seasonid REFERENCES season(seasonid);
答案 0 :(得分:3)
似乎相当不言自明......您需要将FK列名称放在括号中,as shown in the syntax diagram:
CREATE TABLE rosters (
rosterid NUMBER(5) PRIMARY KEY,
playerid NUMBER(5) NOT NULL,
teamid NUMBER(5) NOT NULL,
seasonid NUMBER(5) NOT NULL,
CONSTRAINT fk_player FOREIGN KEY (playerid) REFERENCES players(playerid),
-- ^ ^
CONSTRAINT fk_team FOREIGN KEY (teamid) REFERENCES teams(teamid),
-- ^ ^
CONSTRAINT fk_season FOREIGN KEY (seasonid) REFERENCES season(seasonid));
-- ^ ^ ^
我也为整个声明添加了缺少的右括号。
使用虚构参考表进行快速演示:
CREATE TABLE players (playerid number(5) PRIMARY KEY);
Table PLAYERS created.
CREATE TABLE teams (teamid number(5) PRIMARY KEY);
Table TEAMS created.
CREATE TABLE season (seasonid number(5) PRIMARY KEY);
Table TEAMS created.
CREATE TABLE rosters (
rosterid NUMBER(5) PRIMARY KEY,
playerid NUMBER(5) NOT NULL,
teamid NUMBER(5) NOT NULL,
seasonid NUMBER(5) NOT NULL,
CONSTRAINT fk_player FOREIGN KEY (playerid) REFERENCES players(playerid),
CONSTRAINT fk_team FOREIGN KEY (teamid) REFERENCES teams(teamid),
CONSTRAINT fk_season FOREIGN KEY (seasonid) REFERENCES season(seasonid));
Table ROSTERS created.
答案 1 :(得分:1)
你在赛季后缺少一个右括号(seasonId)。