database table field, default NULL and NOT NULL default

Source: Internet
Author: User

Why do you want to set the field to NOT null?

1, empty value is not space-consuming

2. The null in MySQL is actually occupied space, the following is the explanation from the official MySQL

"NULL columns require additional space in the row to record whether their values is null. For MyISAM tables, each of the NULL column takes one bit extra, rounded up to the nearest byte. "

The conditions for null and NULL queries are not the same, and all the best settings are not null!

If a table field contains null data (null means any value), SQL Server uses three-value logic (True,false,unknown) instead of the usual two-value logic (true,false) when doing a database comparison operation. Therefore, when doing database design, we all want to try to do not set the table to a null type, if the business requirements need to have a null value, we try to use the actual default value instead of NULL (int we use 0, the string can be empty string, etc.), so that the SQL Server does not use the relatively complex three-valued logic when doing the comparison operation, but uses the binary logic.

database table field, default NULL and NOT NULL default

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.