The purpose of creating a unique index is not to increase access speed, but to avoid duplication of data. A unique index can have more than one but the value of the indexed column must be unique, and the value of the indexed column allows for a null value. If you can determine that a data column will contain only values that are different from each other, you should use the keyword unique when creating an index for that data column and define it as a unique index.
Methods for creating unique cables
Action table
CREATE TABLE ' wb_blog ' ( ' id ' smallint (8) unsigned not NULL, ' catid ' smallint (5) unsigned not N ULL default ' 0 ', ' title ' varchar (+) NOT null DEFAULT ' ', ' content ' text is not NULL, PRIMARY KEY (' Id '), )
1. Create a unique cable can be created with the table using the keyword unique
mysql> CREATE TABLE ' Wb_blog ' ( - id ' smallint (8) unsigned not NULL, ' CatID ' smallint (5) unsigned NOT null default ' 0 ', ' title ' varchar (+) NOT null default ',
, ' content ' text not NULL, PRIMARY KEY (' id '), UNIQUE KEY ' catename ' (' catid ') 0 rows affected (0.24 sec)
The above code creates a unique index named Catename for the ' CATID ' field of the Wb_blog table
2. Create a table after creating it using the Create command
Mysql>0 rows affected (0.47 sec)
If you do not need a unique index, you can delete this
Mysql>0 rows affected (0.85 sec)
MySQL's unique index unique