NOT NULL Constraint in SQL - SQL NOT NULL Constraint
NOT Null Constraint is used when we need a column that can not hold any null value. while creating a table when we add a column with NOT Null Constraint then that column can not hold a null value.
Example - There is a student form if the developer defines the mobile number column of the student table as NOT Null value then the user has to enter the mobile number while adding and updating the user can not leave the field empty.
CREATE TABLE Student ( StdID int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255) NOT NULL, StdAge int );
NOT Null on ALTER Table
ALTER TABLE Student MODIFY Age int NOT NULL;
The above SQL query will change the Age column with the NOT NULL constraint of the student table. user can modify the constraint of an existing column.
Hope !!! The above Tutorial on NOT NULL Constraints is helpful for you...
QA acharya
0 Comments