Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I am using Oracle SQL Developer and it says I am "missing left parenthesis", but I don't see what is wrong with the code

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
);
1 comments
  1. 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.

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading