MySql: some constraints did't work in mysql

I installed mysql version 5.5.52 to ubuntu 14.04. Then I created a table Student.

CREATE TABLE Student(
       id int primary key,
       gpa int not null);

Then I put some values.

INSERT INTO Student values(1,3.2);
INSERT INTO Student values(2,null);

In 2nd insert query, I hoped that I’ll be given an error. Instead of there was no error and entered 0 as the value of gpa of id=2.
Actually I’m not an expert person in mysql. Do anybody know how to correct this?.

Probably you need to enable strict mode. AFAIK, strict mode became default since 5.7.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.