Create table: unique value and value from combined columns
/*
mysql> Drop table Product;
mysql> CREATE TABLE Product
-> (
-> ID SMALLINT UNSIGNED NOT NULL,
-> ModelID SMALLINT UNSIGNED NOT NULL,
-> ModelDescrip VARCHAR(40),
-> PRIMARY KEY (ID),
-> UNIQUE (ID, ModelID)
-> );
Query OK, 0 rows affected (0.06 sec)
mysql> Describe Product;
+--------------+----------------------+------+-----+---------+-------+
| 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 Product;
CREATE TABLE Product
(
ID SMALLINT UNSIGNED NOT NULL,
ModelID SMALLINT UNSIGNED NOT NULL,
ModelDescrip VARCHAR(40),
PRIMARY KEY (ID),
UNIQUE (ID, ModelID)
);
Describe Product;
Related examples in the same category