Home > front end >  Alter Table Foreign Key
Alter Table Foreign Key

Time:11-09

I'm trying to add barista_grade_id to the baristas table as a foreign key and I've looked every where on what syntax to use and it seems to be unanimous that this is the correct way.

ALTER TABLE baristas
ADD FOREIGN KEY barista_grade_id REFERENCES barista_grade(barista_grade_id)

I did it before this and it worked. but because of some mistakes I deleted it and redo it again, but for whatever reason it says that it's a syntax error.

CodePudding user response:

The format is like this:

ALTER TABLE baristas
ADD CONSTRAINT FOREIGN KEY (barista_grade_id) REFERENCES barista_grade (barista_grade_id);
  • Related