Today we are going to discuss with you some errors caused by the Data Type of the MySQL database primary key automatically increased, if you encounter the following problems in your actual operations, the task is over. The following is the main content of the article.
Some time ago, when I made a website, I used the MySql database and EMS MySQLManager to create and manage databases. One of the tables has an auto-increment primary key id of the MySQL database, because the default auto-increment data type of EMS MySQLManager when creating a table is TinyInt, this problem was not noticed at the beginning. Today, I found that I cannot insert data into the database.
The error is because the record with the value 127 in the id column already exists! After checking the database, it exists, but the id column is obviously auto-incrementing. I didn't specify the value of the id column in the insert statement. Why does this problem occur?
After checking the database, I found that the data type of the id column is tinyint, and then I thought how could it be such a special number as 127 (128-1? Later I thought whether tinyint can only represent-127 ~ What about the number between 127? As a result, I changed the data type to integer!
It seems that it is important to select the correct database data type.
The above content is an introduction to the error caused by the Data Type of the MySQL database primary key automatically added). I hope you will gain some benefits.