Is it good to use a default of NULL?

16,772

Solution 1

You should set them to Default:Null as if the user doesn't provide any info for that fields, they should be null obviously.

Solution 2

Use NULL, None mode is inserting 'None' or some '' string to indicate that there is nothing there....

For more information why you want to use NULL versus a string look here: MySQL, better to insert NULL or empty string?

Share:
16,772
PHPLOVER
Author by

PHPLOVER

Updated on June 21, 2022

Comments

  • PHPLOVER
    PHPLOVER almost 2 years

    I have some columns that may contain data that is if the user wants to provide it.

    Example | Email | First Name | Last Name |

    Email - Required so column is set to NOT NULL - Default: None

    First Name - Not Required so column set to NULL - Default: NULL

    Last Name - Not Required so column set to NULL - Default: NULL

    In phpmyadmin when creating/editing a column; it has an option saying Default: with a drop down showing None | As Defined | NULL | Current Timestamp

    Because First Name | Last Name is optional and not required should I choose default NULL or maybe NONE?

    Which is best and why please?

    I know there are many discussions on this already but I could not find any that answered my question; they was more in regards to allowing NULL or NOT NULL, my question is about default value.