I have a table as follows:
CREATE TABLE `b` (
`b1` int(11) DEFAULT NULL,
`b2` int(11) DEFAULT NULL,
UNIQUE KEY `b1` (`b1`,`b2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
Here, the unique table constraint is given for 2 fields. But, in the show create table query, it is like UNIQUE KEY b1
(b1
,b2
) Also the first field b1
acts as a unique key in which b2
is combined.
I could drop the constraint of b1
but not b2
:
mysql> alter table b drop index b2;
ERROR 1091 (42000): Can't DROP 'b2'; check that column/key exists
mysql> alter table b drop index b1;
Query OK, 0 rows affected (0.41 sec)
Records: 0 Duplicates: 0 Warnings: 0
Answers needed for :
- Why this unique constraint is applied only for one field(first mentioned field)?
- Is the structure of unique table constraint like that?
- Any attachments of reference links is much needed
Thanks in advance