mysqldatabasesql-null

MySQL NULL or NOT NULL That is The Question?


What is the difference between NULL and NOT NULL? And when should they be used?


Solution

  • NULL means you do not have to provide a value for the field...

    NOT NULL means you must provide a value for the fields.

    For example, if you are building a table of registered users for a system, you might want to make sure the user-id is always populated with a value (i.e. NOT NULL), but the optional spouses name field, can be left empty (NULL)