mysql> status
--------------
mysql Ver 14.14 Distrib 5.7.26, for Linux (x86_64) using EditLine wrapper
Connection id: 29740
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.26 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 6 days 23 hours 30 min 27 sec
Threads: 1 Questions: 1984187 Slow queries: 0 Opens: 1555 Flush tables: 1 Open tables: 947 Queries per second avg: 3.290
--------------
mysql> SHOW VARIABLES LIKE "sql_mode";
+---------------+----------------------------------------------------------------------------------------------------+
| Variable_name | Value |
+---------------+----------------------------------------------------------------------------------------------------+
| sql_mode | NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+----------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> desc test;
+----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | | |
| add_time | int(11) | NO | | 0 | |
+----------+------------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
mysql> INSERT INTO test (`name`, `add_time`) VALUES ('Albert', NULL);
ERROR 1048 (23000): Column 'add_time' cannot be null
mysql> INSERT INTO test (`name`, `add_time`) VALUES ('Albert', NULL),('Ben', NULL);
Query OK, 2 rows affected, 1 warning (0.03 sec)
Records: 2 Duplicates: 0 Warnings: 1
mysql> select * from test;
+----+--------+----------+
| id | name | add_time |
+----+--------+----------+
| 1 | Albert | 0 |
| 2 | Ben | 0 |
+----+--------+----------+
2 rows in set (0.00 sec)