The only indexed keyword in mysql is unique index. Creating a unique index can avoid duplication of data. There can be multiple unique indexes, but the value of the index column must be unique, and the value of the index column is allowed to have null values. A unique index can be created with the table using the keyword UNIQUE.
#The only indexed keyword in mysql is unique index.
(Recommended tutorial: mysql tutorial)
Related introduction:
Creating a unique index can avoid data duplication. There can be multiple unique indexes, but the value of the index column must be unique, and the value of the index column is allowed to have null values. If you can determine that a data column will only contain values that are different from each other, you should use the keyword UNIQUE to define it as a unique index when creating an index for this data column.
Example:
To create a unique index, you can use the keyword UNIQUE to create it with the table
Code implementation:
The above code creates a unique index named catename for the 'catid' field of the wb_blog table.
If you don’t need a unique index, you can delete it:
Code implementation:
mysql> ALTER TABLE wb_blog DROP INDEX catename; Query OK, 0 rows affected (0.85 sec)
The above is the detailed content of What is the unique indexed keyword in mysql. For more information, please follow other related articles on the PHP Chinese website!