Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PL/SQL error ORA-00907

Status
Not open for further replies.

stormking

Programmer
Nov 3, 2001
6
CA
Hi,

I am just starting tolearn Oracle PL/SQL and am getting an error right off the bat that I can't seem to get rid of, here it is:
CREATE TABLE book_copies (
barcode_id VARCHAR2(100) NOT NULL PRIMARY KEY,
isbn VARCHAR2(13) FOREIGN KEY REFERENCES books (isbn)
);

error at line 3:
ORA-00907: missing right parenthesis

I have tried to add another parenthesis, closing spaces and several other things, but it still gives me errors.

I appreciate any help

Thanks

Wendy
 
Try the following :
CREATE TABLE book_copies (
barcode_id VARCHAR2(100) NOT NULL PRIMARY KEY,
isbn VARCHAR2(13),
constraint books_fk FOREIGN KEY (isbn) REFERENCES books
)
 
Just remove the "FOREIGN KEY" from your statement. (Assumed that you already have a table called books.)

When you 'create' a table you don't specify FOREIGN KEY, but
you do if you use 'alter' option.

The Following code will work.

CREATE TABLE book_copies (
barcode_id VARCHAR2(100) NOT NULL PRIMARY KEY,
isbn VARCHAR2(13) REFERENCES books (isbn)
) ;
 
Thanks umeman

It worked, I will store this away for use in the future.

Thanks again. I am sure you'll be seeing me a lot while learning PL/SQL.

Thanks again.

Stormking
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top