To allow naming of a FOREIGN KEY constraint, and for defining a FOREIGN KEY constraint on multiple columns, use the following SQL syntax:CREATE TABLE Orders ( OrderID int NOT NULL, OrderNumber int NOT NULL, PersonID int, PRIMARY KEY (OrderID), CONSTRAINT FK_PersonOrder FOREIGN KEY (Person...
MySQL / SQL Server / Oracle / MS Access:ALTER TABLE Orders ADD FOREIGN KEY (P_Id) REFERENCES Persons(P_Id)To allow naming of a FOREIGN KEY constraint, and for defining a FOREIGN KEY constraint on multiple columns, use the following SQL syntax:...
In MySql, you can accomplish that by following Tom Tresansky response, which will give us this syntax: ALTER TABLE `table_name` DROP FOREIGN KEY `key_name`; ALTER TABLE `table_name` ADD CONSTRAINT `constraint_name` FOREIGN KEY (`new_key_name`) REFERENCES `other_table_name` ('other_tabl...
SQL Server / Oracle / MS Access: CREATETABLEOrders ( OrderID intNOTNULLPRIMARYKEY, OrderNumber intNOTNULL, PersonID intFOREIGNKEYREFERENCESPersons(PersonID) ); To allow naming of aFOREIGN KEYconstraint, and for defining aFOREIGN KEYconstraint on multiple columns, use the following SQL syntax: ...