mysql 修改not null,为什么MySQL允许将NOT NULL列更新为NULL?

I'm running MySql in ubuntu 10.10. I created a table called 'employee' having 3 field names empno, name and salary. Inserted few entities. In the middle of the process i want to change salary attribute as 'NOT NULL'. I Alter the table as

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

Query executed. I wanted to test by using command,

UPDATE employee SET salary=NULL;

Query OK, 15 rows affected, 15 warnings (0.06 sec)

Rows matched: 15 Changed: 15 Warnings: 15

also gave warnings " (Code 1048): Column 'salary' cannot be null "(Repeated for every row)

But when i saw my table , All salaries were Zeros('0').

Same queries result in error instead of warning in WINDOWS XP's MySql

I checked in both INNODB and MYISAM engines but same Result.

Please help me to know what happened beside processing.

解决方案

You must not have SQL_MODE set to strict on you ubuntu installation.

Issue

SET SQL_MODE='STRICT_ALL_TABLES'

or add

SQL_MODE='STRICT_ALL_TABLES'

under [mysqld] to your my.cnf on Ubuntu.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值