create table BookChe (
check number(10) not null,
bookISBN number(13) not null,
bookCopy number(10) not null,
constraint pk_ResChe primary key (check, bookISBN, bookCopy),
constraint fk_ResChe_Che foreign key (check) references checkout,
constraint fk_ResChe_book foreign key (bookISBN, bookCopy) references book
);
>Solution :
check is a reserved word. Don’t use it without double-quotes.
If we change it for example to check_col, it works fine:
create table BookChe (
check_col number(10) not null,
bookISBN number(13) not null,
bookCopy number(10) not null,
constraint pk_ResChe primary key (check, bookISBN, bookCopy),
constraint fk_ResChe_Che foreign key (check) references checkout,
constraint fk_ResChe_book foreign key (bookISBN, bookCopy) references book
);
And example with double-quotes:
create table BookChe (
"CHECK" number(10) not null,
bookISBN number(13) not null,
bookCopy number(10) not null,
constraint pk_ResChe primary key ("CHECK", bookISBN, bookCopy),
constraint fk_ResChe_Che foreign key ("CHECK") references checkout,
constraint fk_ResChe_book foreign key (bookISBN, bookCopy) references book
);
While your 2nd solution works, having object or column names using reserved words like “CHECK” or “TABLE” is highly NOT recommended. That mean now for every time you go to query this table you’ll have to use “CHECK” in your SELECT list vs just say, check.
So go for the first solution, using a different, but similar name.