create table mysql with foreign key
snippet in sql

mysql change foreign key

user8976

ALTER TABLE Orders
ADD FOREIGN KEY (PersonID) REFERENCES Persons(PersonID);

drop foreign key

user7241

ALTER TABLE table_name
DROP CONSTRAINT fk_name;

how to add foreign key in mysql using alter

user6977


ALTER TABLE Orders

ADD CONSTRAINT FK_PersonOrder

FOREIGN KEY (PersonID)
REFERENCES Persons(PersonID); 

create table mysql with foreign key

user6298

CREATE TABLE Orders (
    OrderID int NOT NULL,
    OrderNumber int NOT NULL,
    PersonID int,
    PRIMARY KEY (OrderID),
    FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
);