Home  >  Article  >  Backend Development  >  nullif NOT NULL 和NULL

nullif NOT NULL 和NULL

WBOY
WBOYOriginal
2016-07-29 08:36:141016browse

NOT NULL | NULL: Specifies whether the column is allowed to be empty. If neither NULL nor NOT NULL is specified, the column is considered to have NULL specified.
In MySQL,
Set a NULL value for a NOT NULL field.
It will not go wrong.
MySQL will automatically convert the NULL value to the field. The default value,
Even if you did not explicitly set a default value for the field when defining the table
:》Generally speaking, MySQL will automatically add a default value for you,
For example,
Assign NULL to an integer type of NOT NULL Value,
The result is 0
CHAR type
-> ''null value
DATATIME
->'0000-00-00 00:00:00'
Wait
Top
2nd floor UNICORN_BX (天天天蓝) replied to 2003-01-13 11:22:18 Score 0 In other words, NOT NULL is not a constraint in MySQL.
If a field is set to NULL, then there is no value given to the field when inserting the record, then MySQL automatically uses Default If there is no Default, the field value will be NULL no matter what type the field is.
Is this the role played by NOT NULL and NULL in MySQL, that is, when the Default value is not defined, the default value given The difference in value.

The above introduces nullif NOT NULL and NULL, including the content of nullif. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn