29
May
NULL, NOT NULL and empty
NULL, NOT NULL and empty
A database architect may choose to set database columns to either NULL or NOT NULL. Why is this important? Well, it is important because it may have an impact in how you write your SQL statements. If the columns are set to allow NULL then you do not have to list all your columns on your INSERT statements. That’s because NULL means no need to insert a value. But if the columns are set to NOT NULL then you must write all your columns on your insert statements. On IF control structures, you may check against NULLS. It is important to know that NULL means that no “value” is there. There is nothing in that container. It is not even empty. It just does not exist. NULL means that it does not exist. You can set a field to empty by inserting an empty string. That would mean that something exists in that field (an empty space). It ceases to be nonexistent. It’s now a string with zero characters. Indeed, empty and NULL are not the same thing.