Home >Database >Mysql Tutorial >How to set mysql data to be non-duplicate
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.
【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.
#2. Then fill in a few test contents to demonstrate the test effect.
#3. Select the user name, right-click and select Design Table.
#4. Then switch to the Index tab in the design table.
#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.
#6. Index type selection, here is the key, the uniqueness constraint must choose the Unique type.
#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.
#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.
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!