Why does MySQL allow me to update a NOT NULL column to NULL?

I run MySqlin ubuntu 10.10. I created a table called 'employee'three empno field names , name and salary . Insert multiple objects. In the middle of the process, I want to change the salary attribute as 'NOT NULL'. i change the table as

ALTER TABLE employee MODIFY salary int(10) NOT NULL;

The request is in progress. I wanted to test with the command

UPDATE employee SET salary=NULL;

Query OK, 15 rows affected, 15 warnings (0.06 sec)
Rows matched: 15  Changed: 15  Warnings: 15

also issued warnings " (Code 1048): Column 'salary' cannot be null "(repeated for each line)

But when I saw my table, all salaries were zeros ( '0').

The same queries result in an error instead of a warning in WINDOWS XP MySql

I tested both the INNODB and MYISAM engines, but the same result. Please help me find out what happened next to the processing.

+5
source
2

SQL_MODE ubuntu.

SET SQL_MODE='STRICT_ALL_TABLES'

SQL_MODE='STRICT_ALL_TABLES'

[mysqld] my.cnf Ubuntu.

+11

, NOT NULL ( NULL), NULL, .

, 0s , , 0 NULL int.

+3

All Articles