我似乎无法创建外键,语法可能有问题。以下是表格: -
CREATE TABLE ADMINMEMBER
(
ADMIN_ID INT NOT NULL PRIMARY KEY,
ADMIN_NAME VARCHAR(300) ,
ADMIN_JOB VARCHAR(300)
);
CREATE TABLE TRAINER
( TRAINER_ID INT NOT NULL PRIMARY KEY
, TRAINER_NAME VARCHAR(300)
, TRAINER_SPECIALITY VARCHAR(300)
, TRAINER_JOINDATE DATE
, ADMIN_ID int constraint FKF REFERENCES ADMINMEMBER(ADMIN_ID)
);
任何人都可以告诉我我做错了什么或如何成功创建外键?
答案 0 :(得分:1)
您的语法错误。将第二个表的create语句更改为:
CREATE TABLE TRAINER
( TRAINER_ID INT NOT NULL PRIMARY KEY
, TRAINER_NAME VARCHAR(300)
, TRAINER_SPECIALITY VARCHAR(300)
, TRAINER_JOINDATE DATE
, ADMIN_ID int
, FOREIGN KEY (ADMIN_ID) REFERENCES ADMINMEMBER(ADMIN_ID)
);