Не уверен, почему я получаю ORA-00906: отсутствует ошибка в левой скобке.Не могу найти пропущенные скобки - PullRequest
0 голосов
/ 12 февраля 2019

Невозможно найти пропущенные скобки или выяснить, почему я получаю сообщение об ошибке.

    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 столбцами.

1 Ответ

0 голосов
/ 12 февраля 2019

Должно быть так:

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>
...