NOTNULL and NULL

Source: Internet
Author: User
NOTNULL and null not null | NULL: specifies whether the column can be empty. If neither NULL nor not null is specified, the column is considered NULL
In MySQL,
Set a NULL value for a not null field,
It does not make errors,
MySQL automatically converts the NULL value to the default value of this field,
You may not explicitly set the default value for this field during table definition.
: "In general, MySQL will automatically add default values for you,

For example
Assigns a NULL value to an integer not null,
The result is 0.

CHAR type
-> '': NULL value

DATATIME
-> '2014-00-00 00:00:00'

And so on.
Top

On the second floor, UNICORN_BX (Daily blue) replied with a score of 0 from 11:22:18. that is to say, not null in MySQL is NOT a constraint.

If the field is set to NULL, the value of this field is not given when the record is inserted. MySQL automatically uses the Default value. If no Default value exists, no matter what type the field is, the field value is NULL.

This is the role of not null and NULL in MySQL, that is, the Default value is different when the Default value is NOT defined.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.