mysql> set sql_mode="NO_AUTO_VALUE_ON_ZERO";
mysql> insert into d select 0; Query OK, 1 row affected (0.19 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> select * from d; +---+ | a | +---+ | 0 | +---+ 1 row in set (0.19 sec) mysql> insert into d select null; Query OK, 1 row affected (0.18 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> select * from d; +---+ | a | +---+ | 0 | | 1 | +---+