The solution of Multiple primary key defined error report in MySQL
There are two ways to create a primary key:
Create table table name (field name type, field name type,... Primary key (name))
Or
Create table table name (field name type primary key, field name type, …)
Note, however, that if you want to create a compound primary key, you cannot use the second way.
Here is a small example:
An error Multiple primary key defined is reported here, which means that multiple primary keys are defined. The correct way to write it is as follows:
If the item sets a compound primary key, the compound primary key is created and deleted at the same time, so you need to delete the primary key, but here you need to delete the primary key, and you need to delete the primary key first. If you don't delete the primary key first, you will report an error if you delete the primary key directly (as follows).
Self-increment needs to be deleted first:
Here, if we create a compound primary key, delete the normal index on the name field, and then create the compound primary key for both the stu_id and name fields:
Summary: there are two ways to create a primary key at the beginning of the article, the second way can not be used when creating a compound primary key; the compound primary key should be created and deleted at the same time.
The above is the solution to the Multiple primary key defined error prompt in MySQL. Thank you for your reading and support.