SQL NOT NULL Constraint


The attribute or column in a table which has NOT NULL constriant Specifies that
Null value is not permitted for that attribute .


 Ex :- Lets see the declaration of NOT NULL constraint during creation of table




                           Create table Member(
                                            member_id            int  Primary Key ,
                                                       name       varchar(30) NOT NULL ,
                                                     country   varchar(30)
                                                   ) ;   



             



In the above defined Member table the column name is declared with constraint NOT NULL .

 Inserting values :-

Incorrect : 



Insert into Member(1," "," india ");


                   

             Error:-Null value is not permitted
As you can see in the above insertion operation for Member table, the name column is not inserted
with value so the database throws the error message .



 Correct : 



Insert into Member(1,"Pavan","india");


                     

Member

member_id name country
1 pavan deshpande india bharat

No comments:

Post a Comment