Home » SQL & PL/SQL » SQL & PL/SQL » Help for a noobie!
Help for a noobie! [message #683102] Thu, 03 December 2020 01:39 Go to next message
nail3r
Messages: 1
Registered: December 2020
Junior Member
I'm trying to create a table with the following PK's and FK's:

CREATE TABLE result (

SubjectNo varchar2(Cool,
StudentNo varchar2(Cool,
Result varchar2(1) CONSTRAINT res_res_passfail_ck CHECK
(result IN ('P','F')),
CONSTRAINT res_subno_studno_pk PRIMARY KEY(SubjectNo, StudentNo),
CONSTRAINT res_subno_fk FORIEGN KEY(SubjectNo)
REFERENCES subject(SubjectNo),
CONSTRAINT res_studno_fk FORIEGN KEY(StudentNo)
REFERENCES student(StudentNo));

I keep getting the error message ORA-00907: missing right parenthesis. Can anyone tell me what I've gotten wrong?
Re: Help for a noobie! [message #683105 is a reply to message #683102] Thu, 03 December 2020 04:17 Go to previous message
Michel Cadot
Messages: 67850
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Welcome to the forum.
Please read the OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Indent the code, use code tags and align the columns in result.

Also always post your Oracle version, with 4 decimals (query v$version), as often solution depends on it.

SQL> CREATE TABLE result (
  2    SubjectNo varchar2(8),
  3    StudentNo varchar2(8),
  4    Result varchar2(1) CONSTRAINT res_res_passfail_ck CHECK (result IN ('P','F')),
  5    CONSTRAINT res_subno_studno_pk PRIMARY KEY(SubjectNo, StudentNo),
  6    CONSTRAINT res_subno_fk FORIEGN KEY(SubjectNo) REFERENCES subject(SubjectNo),
  7    CONSTRAINT res_studno_fk FORIEGN KEY(StudentNo) REFERENCES student(StudentNo));
  CONSTRAINT res_subno_fk FORIEGN KEY(SubjectNo) REFERENCES subject(SubjectNo),
                                     *
ERROR at line 6:
ORA-00907: missing right parenthesis
FORIEGN <> FOREIGN

Previous Topic: Need help to rewrite the query
Next Topic: string_api package that... has no body?
Goto Forum:
  


Current Time: Sat May 15 12:58:49 CDT 2021