1. Create a database:
Create DATABASE User (
UID int NOT NULL,
Username varchar (+) NOT NULL,
Password varchar (+) is not NULL.
Primary KEY (UID)
);
The primary key for the database created by the statement is user, but there is no setting to increment the field, and the first data starts at 0. An error occurs when inserting a second data into the database without specifying the UID. So how do you modify the field to make it self-increment?
Alert table User Modify UID int (4) Auto_increment primary key.
Input change statement will be reported: multiple primary key defined, duplicate definition of primary key error
The modified statement of the integer error is: Alert table user Modify UID int (4) auto_increment;
So the primary key uid is self-increment, and the database automatically modifies the UID field of the first record inserted, changing 0 to 1.
MySQL database changes the primary key self-increment and the problem occurs