1

I've been looking over the following SQL code for awhile and just can't seem to find the problem. I'm relatively new to SQL, so I'm sure it's just something I'm overlooking. The error message I get is: ORA-01735: Invalid ALTER TABLE option.

Code:

ALTER TABLE PATIENT
(
ADD CONSTRAINT PProfileForeignKey
    FOREIGN KEY (pProfileID) REFERENCES PATIENT_PROFILE(Profile_ID),
ADD CONSTRAINT InsForeignKey
    FOREIGN KEY (pInsID) REFERENCES INSURANCE(Insurance_ID)
        ON DELETE SET NULL
);

I have triple checked to make sure the foreign key column names and the referenced column names are correct.

4
  • @GordonLinoff, Same error unfortunately. Commented Mar 27, 2016 at 16:31
  • Can you specify multiple Foreign Keys in a single ALTER TABLE statement? Try splitting it in two... Commented Mar 27, 2016 at 16:37
  • @dnoeth, I think that was the problem, thank you! Commented Mar 27, 2016 at 16:48
  • @dnoeth thanks ... wrong comment removed Commented Mar 27, 2016 at 16:55

1 Answer 1

1

seems The parentheses are in wrong place

ALTER TABLE PATIENT
 ADD (CONSTRAINT PProfileForeignKey
    FOREIGN KEY (pProfileID) REFERENCES PATIENT_PROFILE(Profile_ID),
    CONSTRAINT InsForeignKey
    FOREIGN KEY (pInsID) REFERENCES INSURANCE(Insurance_ID)
        ON DELETE SET NULL);
Sign up to request clarification or add additional context in comments.

2 Comments

Correction, if you saw my first comment. This did work on another ALTER TABLE, I must have done something wrong the first time. Thank you!
@Zarch thank you very much ... I was sure that would work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.