Create table: REFERENCES
/*
mysql> Drop table Orders;
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE TABLE Orders
-> (
-> ID SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
-> ModelID SMALLINT UNSIGNED NOT NULL REFERENCES Models (ModelID),
-> ModelDescrip VARCHAR(40)
-> );
Query OK, 0 rows affected (0.06 sec)
mysql> Describe Orders;
+--------------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+----------------------+------+-----+---------+-------+
| ID | smallint(5) unsigned | | PRI | 0 | |
| ModelID | smallint(5) unsigned | | | 0 | |
| ModelDescrip | varchar(40) | YES | | NULL | |
+--------------+----------------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
*/
Drop table Orders;
CREATE TABLE Orders
(
ID SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
ModelID SMALLINT UNSIGNED NOT NULL REFERENCES Models (ModelID),
ModelDescrip VARCHAR(40)
);
Describe Orders;
Related examples in the same category