SQL oracle错误,外键约束问题

时间:2017-04-14 17:07:34

标签: oracle

我有多个表格:

  • 学生(学生ID [pk],学生姓名)

  • 合格(FID [pk],CourseID [pk],dateQ)

  • 教师(FID [pk],Fname)

  • 课程(CourseID [pk],CourseName)

我需要再创建2个,SectionRegistration

  • 部分(SectionNo [pk],学期[pk],CourseID [pk])

  • 注册(StudentID [pk],SectionNo [pk],学期[pk])

我首先创建没有任何问题的部分:

create table section(
SectionNo number(28) not null,
Semester varchar(25) not null,
CourseID varchar(25) not null,
constraint sec_pk primary key(SectionNo,Semester,CourseID),
constraint sec_fk foreign key(CourseID) references Course(CourseID)
on delete cascade);

然后我尝试创建一个名为registration的表,但它在标题中给出了错误。

create table registration(
StudentID number(28) not null,
SectionNo number(28) not null,
Semester varchar(25) not null,
constraint reg_pk primary key(SectionNo,StudentID,Semester),
constraint reg_fk foreign key(StudentID) references Student(StudentID)
on delete cascade,
constraint reg_fk2 foreign key(SectionNo,Semester) references 
Section(SectionNo,Semester) on delete cascade);

0 个答案:

没有答案