I am using MySQL, I have a table called student as given below,
Name Idnumber
'tony' 1
'jimmy' 2
I am going to add one more column using the below query
alter table student add location varchar(20) not null;
Now, if I use the query,
update student set location=null where name='tony'
the value of null is being inserted into the table. Below was the table I got.
Name IdNumber location
'tony' 1 null
'jimmy' 2
Since I had set location as not null while altering the table, why is it still accepting null? Also, if I tried to insert null using,
insert into student(Name,IdNumber) values('robert',3);
the query is not demanding a not null value for location. 'Not Null' constraing is only working when I use the query,
insert into student (Name,IdNumber,location) values('john',8,null);
Please tell my why 'not null' constraint is not working in the other cases described above.
Thanks, Vivek G