UK [ˈfɔrin ki:] US [ˈfɔrɪn ki]

foreign keywords

mysql FOREIGN KEY constraint syntax

Function:The FOREIGN KEY in one table points to the PRIMARY KEY in another table.

Description:FOREIGN KEY constraints are used to prevent actions that destroy connections between tables. The FOREIGN KEY constraint also prevents illegal data from being inserted into the foreign key column because it must be one of the values in the table it points to.

mysql FOREIGN KEY constraint example

//在 "Orders" 表创建时为 "Id_P" 列创建 FOREIGN KEY CREATE TABLE Orders(Id_O int NOT NULL,OrderNo int NOT NULL,Id_P int,PRIMARY KEY (Id_O),FOREIGN KEY (Id_P) REFERENCES Persons(Id_P));