Create table: two columns for primary key
/*
mysql> Drop table Orders;
mysql> CREATE TABLE Orders
-> (
-> ID SMALLINT UNSIGNED NOT NULL,
-> ModelID SMALLINT UNSIGNED NOT NULL,
-> Descrip VARCHAR(40),
-> PRIMARY KEY (ID, ModelID)
-> );
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 | | PRI | 0 | |
| Descrip | varchar(40) | YES | | NULL | |
+---------+----------------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
*/
Drop table Orders;
CREATE TABLE Orders
(
ID SMALLINT UNSIGNED NOT NULL,
ModelID SMALLINT UNSIGNED NOT NULL,
Descrip VARCHAR(40),
PRIMARY KEY (ID, ModelID)
);
Describe Orders;
Related examples in the same category