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

How to set auto-increment ID in mysql

王林
王林Original
2020-10-16 14:10:506139browse

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开始)
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)

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!

Statement:
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