无法找到丢失的括号或弄清楚为什么我得到的错误。
create table course(
CourseNum number(10) constraint course_CourseNum_pk primary key,
courseName varchar2(40),
startDate date,
endDate date,
Ins_ID varchar2(10),
constraint course_Ins_ID_fk foreign key
references instructor(Ins_ID)
);
期待与5列的表被创建。
应该是这样的:
SQL> create table instructor (ins_id varchar2(10) primary key);
Table created.
SQL> create table course(
2 CourseNum number(10) constraint course_CourseNum_pk primary key,
3 courseName varchar2(40),
4 startDate date,
5 endDate date,
6 Ins_ID varchar2(10),
7 constraint course_Ins_ID_fk foreign key (ins_id) --> you're missing "(ins_id)" here
8 references instructor (Ins_ID)
9 );
Table created.
SQL>
或者,也可以使用:
SQL> create table course(
2 CourseNum number(10) constraint course_CourseNum_pk primary key,
3 courseName varchar2(40),
4 startDate date,
5 endDate date,
6 Ins_ID varchar2(10) constraint course_Ins_ID_fk references instructor (Ins_ID)
7 );
Table created.
SQL>