1
CREATE TABLE MARINA_SLIP
(
SLIP_ID VARCHAR(4),
MARINA_NUM VARCHAR(4),
SLIP_NUM VARCHAR(4),
LENGTH INT,
RENTAL_FEE DECIMAL(8,2),
BOAT_NAME VARCHAR(50),
BOAT_TYPE VARCHAR(50),
OWNER_NUM VARCHAR(4),
CONSTRAINT MARINA_SLIP_SLIP_ID_PK PRIMARY KEY (SLIP_ID),
CONSTRAINT MARINA_SLIP_MARINA_NUM_FK FOREIGN KEY (MARINA_NUM),
CONSTRAINT MARINA_SLIP_OWNER_NUM_FK FOREIGN KEY (OWNER_NUM) REFERENCES OWNER (OWNER_NUM)
);

The error states:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' CONSTRAINT MARINA_SLIP_OWNER_NUM_FK FOREIGN KEY (OWNER_NUM) REFERENCES OWNER (O' at line 12

Does anyone know why this won't work?

Edit: this was figured out for me, small mistake on not including a foreign key reference.

2
  • The first foreign key isnt referencing any column... Commented Sep 2, 2017 at 23:18
  • @JaskaranbirSingh thank you for pointing that out. I'm in a beginning SQL class, where essentially I copied the constraints, and the foreign key reference was pushed a line down. Obvious mistake that I spent 30 minutes trying to figure out. Thank you! Commented Sep 2, 2017 at 23:21

1 Answer 1

1

add REFERENCES to CONSTRAINT MARINA_SLIP_MARINA_NUM_FK FOREIGN KEY (MARINA_NUM) for example CONSTRAINT MARINA_SLIP_MARINA_NUM_FK FOREIGN KEY (MARINA_NUM) REFERENCES OWNER (MARINA_NUM)

Sign up to request clarification or add additional context in comments.

Comments

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.