Ensure that a column cannot contain NULL values Automatically generate values for columnsSubmit Answer » What is an Exercise? Test what you learned in the chapter: MySQL FOREIGN KEY by completing 5 relevant exercises. To try more MySQL Exercises please visit our MySQL Exercises page.
请参阅此链接:https://www.w3schools.com/sql/sql_foreignkey.asp
AFOREIGN KEYis a field (or collection of fields) in one table, that refers to thePRIMARY KEYin another table. The table with the foreign key is called the child table, and the table with the primary key is called the referenced or parent table. ...
SQL FOREIGN KEY on CREATE TABLE The following SQL creates aFOREIGN KEYon the "PersonID" column when the "Orders" table is created: MySQL: CREATETABLEOrders ( OrderID intNOTNULL, OrderNumber intNOTNULL, PersonID int, PRIMARYKEY(OrderID), ...