MySQL NOT NULL

Profile picture for user arilio666

When this constraint is applied, it ensures that the column is responsible for not holding NULL values.

Example

Using NOT NULL during table creation.

CREATE TABLE office (
emp_ID int NOT NULL,
emp_fName varchar(255) NOT NULL,
emp_lName varchar(255) NOT NULL,
Age int
);

Here, we created a table named office with three columns that accept non-NULL values.

Let us try uploading null values into this table and see what happens.

INSERT INTO office (emp_ID,emp_fName,Age)
VALUES(13,’Steven’,30);

not null check in mysql

Tags