About the NOT null field problem with MySQL
Today, I have a very painful problem, about MySQL database, a set NOT null integer field, the default value is 2, when I insert a null value to the field, why is the system default auto-generated integer default value 0, not my custom default value 2, very tangled, if I do not do any action on the field, it will automatically populate the custom default values, why this, ask Gao, thank you ....
------Solution--------------------
A null value is also a value, that is, the default value is not used. If you leave blank, the default value will be used.
Well, that's a good understanding.
------Solution--------------------
Null means nothing at all
Since the value Type field is set to NOT NULL
So nothing in math is 0?
------Solution--------------------
If you are self-defined default value, do not set to not NULL, when inserted directly without this field, is the default value
Cannot be empty meaning you have to insert a value, even if it is a null value, the default value is useless.
------Solution--------------------
Explore
WorkID ' int (ten) unsigned not NULL default ' 3 '
When I insert a null value into this field, why does it become 0?
Reference:
If you are self-defined default value, do not set to not NULL, when inserted directly without this field, is the default value
Cannot be empty meaning you have to insert a value, even if it is a null value, the default value is useless.
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.