NOT NULL in SQL

In SQL, the NOT NULL constraint is used to specify that a column cannot contain any NULL values. When you define a column with the NOT NULL constraint, it means that every row inserted into the table must have a value for that column.

Here's an example of how you can use the NOT NULL constraint when creating a table:

sqlCopy codeCREATE TABLE Employee (
    ID INT PRIMARY KEY,
    Name VARCHAR(50) NOT NULL,
    Age INT NOT NULL,
    Department VARCHAR(50)
);

In this example, both the Name and Age columns have the NOT NULL constraint specified, meaning that every entry in the Employee table must have values for these columns. If you try to insert a row without providing a value for a NOT NULL column, the database will throw an error. Practice with this free SQL compiler!