Home > Database > Mysql Tutorial > How to set auto-increment ID in mysql

How to set auto-increment ID in mysql

王林
Release: 2020-10-19 10:56:53
Original
6231 people have browsed it

Mysql method to set auto-increment ID: execute the [CREATE TABLE empautoinc(ID INT PRIMARY KEY AUTO_INCREMENT) AUTO_INCREMENT = 0;] statement.

How to set auto-increment ID in mysql

The auto-increment column of MYSQL must be an indexed column, and the seed value must be set at the end of the table.

(Recommended tutorial: mysql video tutorial)

--mysql-- 
设置自增ID从N开始
CREATE TABLE empautoinc(
ID INT  PRIMARY KEY AUTO_INCREMENT
) AUTO_INCREMENT = 100 ; --(设置自增ID从100开始)
Copy after login
insert into empautoinc(id) values(null);
Query OK, 1 row affected (0.00 sec)
mysql> select * from empautoinc;
+-----+
| ID |
+-----+
| 100 |
+-----+
1 row in set (0.00 sec)
Copy after login

Related recommendations: mysql tutorial

The above is the detailed content of How to set auto-increment ID in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template