Home >Database >Mysql Tutorial >How to set mysql data to be non-duplicate

How to set mysql data to be non-duplicate

coldplay.xixi
coldplay.xixiOriginal
2020-08-25 10:47:494528browse

How to set non-duplicate mysql data: First use navicat to connect to the mysql database, and select the user name, right-click and select the design table; then switch to the index tab in the design table and select the fields that require unique constraints ;Finally, the Unique type is constrained to be selected.

How to set mysql data to be non-duplicate

【Related learning recommendations: mysql learning

Mysql data setting method that does not repeat:

1. Use navicat to connect to the mysql database and create a new user table.

How to set mysql data to be non-duplicate

#2. Then fill in a few test contents to demonstrate the test effect.

How to set mysql data to be non-duplicate

#3. Select the user name, right-click and select Design Table.

How to set mysql data to be non-duplicate

#4. Then switch to the Index tab in the design table.

How to set mysql data to be non-duplicate

#5. In this step, start adding an index. If there is no requirement for the index name, it can be left blank by default. The tool will automatically generate a name that is the same as the field name. Click the button behind the field to display a selection box, select the field that requires unique constraints, here we have the login name field.

How to set mysql data to be non-duplicate

#6. Index type selection, here is the key, the uniqueness constraint must choose the Unique type.

How to set mysql data to be non-duplicate

#7. After finally adding the unique index, modify the login name of the third piece of data to be bb, which is the same as the second piece, and then click the check button below to save it.

How to set mysql data to be non-duplicate

#8. At this time, an error will be reported when saving, prompting "Duplicate entry 'bb' for key 'login_name'". Duplicate login names cannot be saved successfully, indicating that adding The uniqueness constraint takes effect.

How to set mysql data to be non-duplicate

The above is the detailed content of How to set mysql data to be non-duplicate. 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

Related articles

See more