A NOT NULL constraint on a column does not allow to enter a NULL value. This enforces a field to always contain a value, which means that you cannot insert a new record, or update a record without adding a value to this field.
By default, every column can hold a NULL value.
NOT NULL Constraint on CREATE TABLE
In the below table tblEmployee EmpID, EmpFirstName, EmpLastName column values are mandatory because of NOT NULL constraint.
The EmpID column is a PRIMARY KEY column which does not accept NULL values and EmpFirstName and EmpLastName has NOT NULL constraints, therefore these columns does not accept NULL values.
CREATE TABLE tblEmployee
EmpID INT PRIMARY KEY,
EmpFirstName NVARCHAR(20) NOT NULL,
EmpLastName NVARCHAR(20) NOT NULL,
NOT NULL Constraint on ALTER TABLE
ALTER TABLE tblEmployee
MODIFY EmpSalary INT NOT NULL
Now, If I try to insert NULL value for EmpLastName, I will get an error as shown in the below image.