In SQL, A column in the table can have null values by default. We can use the NOT NULL constraint to not allow the user to enter null values in that particular column. In the following query, we cannot enter null values to the ‘ID’, ‘First_Name’, ‘Last_Name’ columns since not null constraint is specified for those columns:
CREATE TABLE Employee (
ID int NOT NULL,
Last_Name varchar(255) NOT NULL,
First_Name varchar(255) NOT NULL,
Age int
);
You can the following ALTER statement to add NOT NULL constraint to columns of an existing table:
ALTER TABLE Persons
MODIFY Age int NOT
You can go through SQL tutorial by Intellipaat to learn more NOT NULL constraint and other key constraints.