Values are inserted in a row according to what is specified in the INSERT statement. If no value is specified for a column,
the inserted value depends on column settings such as whether to allow NULLs, whether to use a DEFAULT, and so on. Sometimes
the insert operation fails and an error is returned. The following table shows the possible outcomes depending on the value
being inserted (if any) and the column settings:
Value being inserted
Nullable
Not nullable
Nullable, with DEFAULT
Not nullable, with DEFAULT
Not nullable, with DEFAULT AUTOINCREMENT or DEFAULT [UTC] TIMESTAMP
<none>
NULL
SQL error
DEFAULT value
DEFAULT value
DEFAULT value
NULL
NULL
SQL error
NULL
SQL error
DEFAULT value
specified value
specified value
specified value
specified value
specified value
specified value
By default, columns allow NULL values unless you explicitly state NOT NULL in the column definition when creating a table.
You can alter this default using the allow_nulls_by_default option. You can also alter whether a specific column allows NULLs
using the ALTER TABLE statement.
You can explicitly insert NULL into a column by entering NULL. Do not enclose this in quotes, or it will be taken as a string.
For example, the following statement explicitly inserts NULL into the DepartmentHeadID column:
INSERT INTO Departments
VALUES ( 703, 'Western Sales', NULL );
You can define a column so that, even though the column receives no value, a default value automatically appears whenever
a row is inserted. You do this by supplying a default for the column.