The method of setting self-increasing fields in existing tables by mysql
This article mainly introduces mysql in the existing table to set self-increasing field method, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
Mysql sets the self-increasing field in the existing table: 1, add the field, the code is [alter table xiami add id int;]; 2, modify the field, the code is [alter tabel xiami change id id auto_increment].
Mysql's method of setting self-increment fields in existing tables:
Step 1: add a field
Alter table xiami add id int
Step 2: modify the field
Alter tabel xiami change id id auto_increment not null primary key
Question:
The number of records in the table is 3929966
Query OK, 3929966 rows affected (2 min 8.09 sec) Records: 3929966 Duplicates: 0 Warnings: 0 when viewing the create table command, auto_increment is 3932618 > > show create table xiami .. ENGINE=InnoDB AUTO_INCREMENT=3932618 DEFAULT CHARSET=utf8 thank you for reading this article carefully. I hope the article "mysql how to set self-increasing fields in existing tables" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!