Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify the self-increment of mysql

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to modify the self-appreciation of mysql". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to modify the self-appreciation of mysql"!

After we understand the concept of self-increment, we need to further master the self-increment modification method. Let's take a look at the specific modification method.

If the field id is defined as AUTO_INCREMENT, the self-increment behavior is as follows when inserting a row of data:

1. If the id field is specified as 0, null, or no value when inserting data, the AUTO_ index value is filled in the self-increment field.

2. If a specific value is specified at the time of insertion, the value specified in the statement is used directly.

Suppose the value of a minor insert is X, and the current self-increment is Y.

If it's X.

If X > = Y, you need to change the current self-increment to a new self-increment.

Example

CREATE TABLE `t` (`id` int (11) NOT NULL AUTO_INCREMENT, `c` int (11) DEFAULT NULL, `d` int (11) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `c` (`c`) ENGINE=InnoDB

Suppose that there is already a record in table t, and then execute another insert data command:

Insert into t values (null, 1, 1); at this point, I believe you have a deeper understanding of "how to modify the self-added value of mysql". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report