SQL NOT NULL


A NULL is not the same as no data.

NOT NULL constraint restricts a column from having a NULL value. Once NOT NULL constraint is applied to a column, you cannot pass a null value to that column. It enforces a column to contain a proper value. One important point to note about NOT NULL constraint is that it cannot be defined at table level.

Example
CREATE TABLE emp
(
e_id INT NOT NULL,
lastName VARCHAR(255) NOT NULL,
firstName VARCHAR(255),
address VARCHAR(255),
)

Share this article on