Inserting a Zero Value In an AUTO_INCREMENT Column

(Doc ID 2135717.1)

Last updated on JUNE 09, 2016

Applies to:

MySQL Server - Version 4.0 and later
Information in this document applies to any platform.
Zero is used as a literal value for auto_increment columns


The manual states on an INSERT into an auto_increment column, 0 is treated exactly in the same way as NULL, that is, 0 should be replaced with the next sequence number.

Yet '0' itself is inserted:

mysql> CREATE TABLE t2 (a int AUTO_INCREMENT, b int, primary key (a)) engine=innodb;

mysql> insert into t2 (a,b) values(0,0);

Query OK, 1 row affected (0.01 sec)

mysql> select * from t2;
| a | b |
| 0 | 0 |


Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms