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