As the message says, you need to increase the length of the column so that it matches the length of the data you are trying to insert ( 0000-00-00)
EDIT 1 :
Following your comment, I run a test pattern:
mysql> create table testDate(id int(2) not null auto_increment, pdd date default null, primary key(id)); Query OK, 0 rows affected (0.20 sec)
Insert:
mysql> insert into testDate values(1,'0000-00-00'); Query OK, 1 row affected (0.06 sec)
EDIT 2:
So, maybe you want to insert a NULL value in the pdd field as indicated in your comment? You can do this in two ways:
Method 1:
mysql> insert into testDate values(2,''); Query OK, 1 row affected, 1 warning (0.06 sec)
Method 2:
mysql> insert into testDate values(3,NULL); Query OK, 1 row affected (0.07 sec)
EDIT 3:
Failed to change the default value for the pdd field. Here is the syntax how to do it (in my case, I set it to NULL at the beginning, now I will change it to NOT NULL)
mysql> alter table testDate modify pdd date not null; Query OK, 3 rows affected, 1 warning (0.60 sec) Records: 3 Duplicates: 0 Warnings: 1
user3522371
source share