I set default value in a field NOT NULL.
The sql is as follows.
insert into table_name () values ()
I expected this sql should be rejected by MySQL as a field restricts NULL.
But, the field had a value “”(null character string).
Then, I tried another sql.
insert into table_name (name) values (NULL)
As this sql was rejected, no value was inserted.
MySQL seems to distinguish NULL and “”. Do I have to avoid first sql such as “values ()”?
YES if you are doing an
INSERTwhere in you will not set any values to the NOT NULL columnsand
NO not needed anymore, if you are providing a value on the columns that are NOT NULL on
INSERT.You can refer to this
http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html