In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces what is the compound primary key of the data table in MySQL. It is very detailed and has a certain reference value. Friends who are interested must read it!
The MySQL multi-field primary key can become the compound primary key. Compound primary key is also a kind of primary key that has the same function and definition as primary key.
What is the compound primary key of a data table?
The so-called compound primary key means that the primary key of your table contains more than one field.
For example:
Create table test (name varchar (19), id number, value varchar (10), primary key (name,id)
The name and id fields above are combined to form the compound primary key of your test table
It appears because your name field may have a duplicate name, so add the ID field to ensure the uniqueness of your record.
In general, the less the field length and the number of fields of the primary key, the better
When do I use the compound primary key?
Use a compound primary key only when a primary key cannot uniquely identify the records in this table
Like at times like this.
Commodity brand
Commodity type
Nokia
nine hundred and twenty
Samsung
NOTE2
Nokia
8088
For example, the brands of such products may be duplicated, all of which are Nokia, but the models produced by Nokia manufacturers will not be repeated.
For example, many brands may have a 920 model, but a brand has only one 920 model.
So rely on such a joint primary key to determine the uniqueness of this record.
The above is all the contents of the article "what is the compound primary key of a data table in MySQL". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.