The NOT NULL
constraint ensures that a column cannot contain NULL
values.
Use it for fields that must always have meaningful data.
column_name data_type NOT NULL
CREATE TABLE users ( user_id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, email VARCHAR(150) NOT NULL, age INT );
ALTER TABLE users MODIFY COLUMN age INT NOT NULL;
ALTER TABLE users MODIFY COLUMN email VARCHAR(150) NULL;
NOT NULL
,
ensure there are no NULL
values presentβuse
SELECT * FROM table WHERE column IS NULL;
to check.
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!