HOW TO USE NOT NULL CONSTRAINT IN SQL

NOT NULL in SQL

The NOT NULL constraint in SQL is used to disallow the acceptance of NULL value in a column(s). A column, by default, can hold NULL values.

Example of NOT NULL constraint in SQL server-

CREATE TABLE Students (

  ID INT NOT NULL,

  FirstName VARCHAR(200) NOT NULL,

  Age INT);

NOT NULL constraint creation on existing table-

ALTER TABLE Students

ALTER COLUMN Age INT NOT NULL;


Leave a Reply

Your email address will not be published. Required fields are marked *