EZ

Eduzan

Learning Hub

Eduzan
Eduzan / SQL

SQL Constraints

Definition: The NOT NULL constraint ensures that a column cannot have a NULL value. It is used to enforce 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.

Example:

CREATE TABLE Employees (
    EmployeeID int NOT NULL,
    FirstName varchar(100) NOT NULL,
    LastName varchar(100) NOT NULL
);

Explanation: In this table, EmployeeIDFirstName, and LastName must always have a value and cannot be left blank.

End of lesson.