被translation
声明为not null
,具有默认值''
?如果是这样,将其设置为NULL
anUPDATE
无效,并且 MySQL 正确报告没有更改任何行。也就是说,你正在做相当于UPDATE words SET translation = 'a' WHERE translation = 'a'
.
不过,您应该收到警告。MySQL 命令行客户端报告如下警告:
mysql> UPDATE words SET translation=NULL WHERE translation = '';
Query OK, 0 rows affected, 2 warnings (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 2
要查看警告,请使用以下命令show warnings;
:
mysql> show warnings;
+---------+------+-------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------+
| Warning | 1048 | Column 'translation' cannot be null |
| Warning | 1048 | Column 'translation' cannot be null |
+---------+------+-------------------------------------+