An error occurs in the Data Type of the primary key of the MySQL database.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.