我有两个表,虽然我可以创建第一个,但第二个不会因为以下错误:
FOREIGN KEY(JClientID)REFERENCES CLIENT(ClientID)[near“)”:语法错误] 例外名称:NS_ERROR_FAILURE
这只是一个简单的错误吗?
CREATE TABLE CLIENT
(FName VARCHAR(25) NOT NULL,
LName VARCHAR(25) NOT NULL,
PhoneNum INTEGER(10) NOT NULL,
ClientID CHAR(5) NOT NULL,
PRIMARY KEY (ClientID));
CREATE TABLE JOB
(DateDue DATE() NOT NULL,
JobID CHAR(5) NOT NULL,
JClientID CHAR(5) NOT NULL,
PRIMARY KEY (JobID)
FOREIGN KEY(JClientID) REFERENCES CLIENT(ClientID));
答案 0 :(得分:2)
这是因为您忘记了主键后的逗号:
变化:
CREATE TABLE JOB
(DateDue DATE() NOT NULL,
JobID CHAR(5) NOT NULL,
JClientID CHAR(5) NOT NULL,
PRIMARY KEY (JobID)
FOREIGN KEY(JClientID) REFERENCES CLIENT(ClientID));
是:
CREATE TABLE JOB
(DateDue DATE NOT NULL,
JobID CHAR(5) NOT NULL,
JClientID CHAR(5) NOT NULL,
PRIMARY KEY (JobID),
FOREIGN KEY(JClientID) REFERENCES CLIENT(ClientID));