In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how mysql deletes unique constraints". In daily operation, I believe many people have doubts about how mysql deletes unique constraints. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to delete unique constraints in mysql". Next, please follow the editor to study!
In mysql, you can use "ALTER TABLE" statements and "DROP" keywords to unique constraints, and the syntax is "ALTER TABLE table name DROP INDEX constraint name;"; "ALTER TABLE" can add or subtract constraints, and when used with "DROP", you can delete constraints.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
In mysql, you can use the "ALTER TABLE" statement and the "DROP" keyword to unique (unique) constraints.
The "ALTER TABLE" statement changes the structure of the original table, such as adding or deleting columns (constraints), changing the original column type, renaming the column or table, and so on.
Delete constraints can be implemented when the "ALTER TABLE" statement is used with the "DROP" keyword.
The unique (only) constraint means that the values of fields in all records cannot be repeated. For example, when you add a uniqueness constraint to the id field, the id value of each record is unique and cannot be duplicated. If one of the records has an id value of '0001', then the other record cannot have an id value of '0001' in the table.
The only constraints that are similar to primary key constraints are that they both ensure the uniqueness of the column. The difference is that there can be multiple unique constraints in a table, and columns that set unique constraints allow null values, but only one null value. The primary key constraint can only have one in a table, and null values are not allowed. For example, in the user information table, to avoid duplicate user names in the table, you can set the user name to a unique constraint.
Method of deleting unique (unique) constraint
The syntax format for deleting unique constraints in MySQL is as follows:
ALTER TABLE DROP INDEX
Example:
View constraints in the datasheet tb_dept1
DESC tb_dept1
As you can see, the data table tb_dept1, the name of the specified department is unique; now delete the unique constraint unique_name in the data table tb_dept1
ALTER TABLE tb_dept1 DROP INDEX unique_name
At this point, the study on "how mysql removes unique constraints" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.