[Solved] Field 'id' doesn't have a default value error solution

introduce

This is the journey of the editor's growth path, and also the editor's learning path. Hope to grow up with you guys!

Here are two of my favorite quotes:

To have the most simple life and the most distant dream, even if it will be cold tomorrow, the mountains will be high and the water will be far away, and the road will be far away.

Why should one work hard? The best answer I have ever seen is: because the things I like are expensive, the places I want to go are far away, and the person I love is perfect. Therefore, the editor would like to say: encourage each other! 

The editor encountered it when writing the springboot integration mybatis project. When writing the added method, the error Field 'id' doesn't have a default value appeared, so you don't need to look at anything to find your database directly, and then open it. Design the table, see if the auto-increment is checked below, and if it is not checked, execute it again. (hope it can help you guys)

Right-click the table you are operating on, click Change Table, and you can change the auto-increment of the field

 The figure below is the table that Xiaobian needs to operate, and set the id to auto-increment

 Note: auto-increment can only be numeric

The automatic increment AUTO_INCREMENT in MySQL is conditional

  1. The data type of the column (column) must be numeric (this is easy to understand, and the value can be self-increased)
  2. The column must be indexed, such as defined as the primary key (PRIMARY KEY)

Guess you like

Origin blog.csdn.net/weixin_60387745/article/details/130168977