Home  >  Article  >  Database  >  What is the unique indexed keyword in mysql

What is the unique indexed keyword in mysql

王林
王林Original
2020-07-17 11:02:468537browse

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.

What is the unique indexed keyword in mysql

#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:

What is the unique indexed keyword in mysql

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn