Mysql notnull details

Source: Internet
Author: User
For details about mysql notnull, refer to the following SQL & nbsp; ddl statement: password & nbsp; char (32) & nbsp; not & nbsp; null & nbsp; default & nbsp; "", // If md5 is defined, please refer to the not null details of not & nbs mysql.
For example, an SQL ddl statement:
Password char (32) not null default "", // has md5


Since not null is defined, the user must add a password. is the default value later redundant? In addition, the length is set to 32 bits, and the default value is null,

If it is not null, the default value does not exist. even if it exists, its value attribute does not conform to the attribute conventions of the field? Solution! Share:
------ Solution --------------------
On the contrary

When not null, if you do not enter anything, press the default input.

In other words, it is recommended that you set not null to set default.
------ Solution --------------------
Irrelevant!

Password is just a name, it does not make any sense for the database

Not null default "" aims to: if no value is assigned to it, the default value is null. This parameter can be set by default during insertion.
If it is not null only, this item must have a value during insertion; otherwise, an error occurs.

If the password must have a value, it should be defined
Password char (32) not null,
Instead
Password char (32) not null default "",
------ Solution --------------------
Always give a default
------ Solution --------------------
Reference:
Irrelevant!

Password is just a name, it does not make any sense for the database

Not null default "" aims to: if no value is assigned to it, the default value is null. This parameter can be set by default during insertion.
If it is not null only, this item must have a value during insertion; otherwise, an error occurs.

If the password must have a value, it should be defined
Password char (32) not null,
Instead
Password char (32) not null default "",

Your requirements are as follows:
Password char (32) not null

If the default "" is added, the database will store a string with a length of 0 "without passing the value "".
Null! = ""

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.