I\'ve got a table with several columns making up the primary key. The nature of the data stored allows some of these fields to have NULL values. I have designed
You can use unique key like this:
mysql> CREATE TABLE `test` (
-> `Field1` SMALLINT(5) UNSIGNED NOT NULL,
-> `Field2` DECIMAL(5,2) UNSIGNED NULL DEFAULT NULL,
-> UNIQUE KEY (`Field1`, `Field2`)
-> )
-> COLLATE='latin1_swedish_ci'
-> ENGINE=InnoDB;
Query OK, 0 rows affected (0.03 sec)
mysql>
mysql> desc test
-> ;
+--------+-----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+-----------------------+------+-----+---------+-------+
| Field1 | smallint(5) unsigned | NO | MUL | NULL | |
| Field2 | decimal(5,2) unsigned | YES | | NULL | |
+--------+-----------------------+------+-----+---------+-------+
2 rows in set (0.01 sec)