Reputation: 529
I just came to know that mysql MyISAM
engine doesn't support foreign keys.But i have seen several example of declaring foreign
keys like below :
CREATE TABLE Orders (
OrderID int NOT NULL,
OrderNumber int NOT NULL,
PersonID int,
PRIMARY KEY (OrderID),
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
);
As foreign keys are not supported we would not get the benefits like on update
and on delete
in MyISAM engine.My question is then why we are declaring a field as foreign key in MyISAM engine ?
Upvotes: 0
Views: 578
Reputation: 34232
There is no point of declaring foreign keys with the myisam table type, since this functionality does not exist there. Mysql can parse the foreign key syntax for the myisam table type (meaning no error message will be raised if it encounters an fk definition), making migration from other database products or table engines easier because you do not have to edit the create table
statements to remove them.
Upvotes: 2