デフォルト値で、translation
として宣言されていますか?その場合、に設定しても効果はなく、MySQLは行が変更されていないことを正しく報告します。つまり、と同等のことを行っています。not null
''
NULL
UPDATE
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 |
+---------+------+-------------------------------------+