NOT NULL Keyword
The NOT NULL keyword or constraint is used to ensure that no null values are allowed in a column.
If NOT NULL constraints are applied to that column, you cannot insert or update it without adding value.
SQL NOT NULL ON CREATE TABLE
CREATE TABLE <TABLE_NAME>(
<COLUMN_NAME> <DATATYPE> NOT NULL
);
Example
CREATE TABLE Employee(
Emp_Id Integer Primary Key,
Emp_Name Varchar(50) NOT NULL,
Emp_Salary Integer NOT NULL,
);
SQL NOT NULL ON ALTER TABLE
ALTER TABLE <TABLE_NAME>
MODIFY <COLUMN_NAME> <DATATYPE> NOT NULL;
Example
ALTER TABLE Employee
MODIFY Emp_Dept Varchar(50) NOT NULL;
Summary
The NOT NULL keyword or constraint is used to prevent users from adding null values to the column.