【发布时间】:2016-09-21 02:52:12
【问题描述】:
这是我要创建的表。但是,我收到错误
SQL 错误:ORA-02270:此列列表没有匹配的唯一键或主键
SQL:
create table Meets_In
(
cid char(20),
rno integer,
time char(20),
CONSTRAINT PRIM_KEY PRIMARY KEY(time),
constraint meets_fk1 foreign key(cid) references COURSES(CID),
constraint meets_fk2 foreign key(rno) references ROOMS(RNO)
);
这些是父表:
create table Courses
(
cid char(20),
cname char(20),
credits integer,
constraint CoursesKey Primary Key (cid, cname)
);
CREATE TABLE ROOMS
(
rno INTEGER,
address CHAR(20),
capacity INTEGER,
CONSTRAINT room_key PRIMARY KEY(rno)
);
我不明白为什么会收到此错误。
【问题讨论】:
-
可能是因为
time是(某些版本的)SQL 中的保留字。您可以尝试重命名它。 -
试过了,还是不行。我得到同样的错误。
-
为什么需要在表
courses的主键中包含cname?cid不是已经是唯一标识符了吗? (如果不是,为什么不呢?)
标签: sql database oracle oracle11g oracle-sqldeveloper