MySQL 更新:可空列出错,即使有值也是如此

huangapple go评论87阅读模式
英文:

Mysql UPDATE: nullable column gives error although there is a value

问题

SQL怪异!我正在使用MySQL 8数据库,并向表发送了一个更新语句:

UPDATE katalog
       SET katalog_status_id      = '1',
           lieferantennr          = '510181',
           artikelnummer          = '12345678',
           artikelbeschreibung    = 'dgdfgdfgdfg',
           artikelbeschreibung_en = '',
           kommentar              = 'test test ',
           kategorie_a            = '910',
           kategorie_b            = '270',
           datum_aenderung        = '2023-06-15 14:30:42'
       WHERE catalog_id = '21302'

出现了两个问题:
我收到了以下错误消息:

[2023-06-15 14:32:10] [23000][1048] Column 'datum_aenderung' cannot be null

更奇怪的是,列"datum_aenderung" 可以 为空,而且我已经有包含此列的空数据集。

起初,我以为这里可能有一些框架问题,所以我尝试在控制台中直接执行SQL语句(使用PhpStrom作为IDE),但我仍然收到此错误消息。

我忽略了什么?

英文:

SQL weirdness! I am using a mysql 8 db and send an update statement to a table

UPDATE katalog
       SET katalog_status_id      = '1',
           lieferantennr          = '510181',
           artikelnummer          = '12345678',
           artikelbeschreibung    = 'dgdfgdfgdfg',
           artikelbeschreibung_en = '',
           kommentar              = 'test test ',
           kategorie_a            = '910',
           kategorie_b            = '270',
           datum_aenderung        = '2023-06-15 14:30:42'
       WHERE catalog_id = '21302'

Two problems:
I get the error message:

[2023-06-15 14:32:10] [23000][1048] Column 'datum_aenderung' cannot be null

and even weirder the column datum_aenderung can be null and I already have datasets containing null for this column.

First I thought I have some framework weirdness here so I tried the sql statement directly in the console (using PhpStrom as IDE), but I still get this error message.

What am I overlooking?

答案1

得分: 1

可能是由于控制katalog表更新操作的触发器导致的。如果存在该触发器,请尝试禁用它。
请注意,您应该检查为什么存在该触发器,它可能对该表是必要的,并且框架添加该触发器可能有原因。

英文:

It might be because of a trigger that is controlling the update operation of the katalog table. Try disabling that trigger if it exists.
Notice that you should check why that trigger is there, it might be necessary to have it on that table, and there might be a reason that the framework added that trigger.

huangapple
  • 本文由 发表于 2023年6月15日 21:14:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76482878.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定