Get the App
SLTechnology News&Howtos  ›  Development  › 

How to modify the self-increment of mysql

Shulou Source: shulou.com Published: 2022-06-03 17:26:46 11月13日 Update

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!

Tags: Value added fields data methods content learning practical deeper one line middle finger interests commands examples practicality practical easy to operate more friends concepts websites Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MariaDB Shulou Tech Info MySQL OPPO Reno