✔ 最佳答案
NULL means nothing or undefined value. NULL is not empty string. NULL is not 0. NULL is not -1.
Technically most object in a database is a list of pointers pointing to a data storage location. NULL means that there is no pointer at all. So NULL save some storage space. If I have a column that pre-allocates storage space (such as CHAR 1024), a null value can save these 1000 bytes, comparing to an empty stringIn those tables that have millions records of address, photo, and other optional data, the use of NULL really makes a big difference.
Since NULL also means undefined in a way. You cannot compare an object will NULL. For example if you sort a column that allows null, some database will put NULL at the top while others in the end. If you set a critiria such as
select * from tableX where anInteger < 10
those records with a NULL value will never show up, no matter it is <10 >10 =10 or <>10.
Primary Key (refer as PK) cannot be NULL because PK mush be unique. In most database, PK is also the cluster index that is used to sort the table. If the sorting of a column differs from database to database, it would be a disaster. Other than this, there is no other technical reason that a PK cannot be NULL. If PK allows NULL, then there can only be 1 record that can have NULL, so it is pretty pointless anyway.
PK cannot be NULL is more of a concept in life rather than a technical limitation. PK is the most important identity of a record, just like the ID of a passport or the social security number. Think about a passport that do not have an ID.