MySQL: 日期字段依赖无法解释

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

MySQL: Inexplicable Date field dependency

问题

I can assist with the translation. Here's the Chinese translation of the code and text you provided:

我正在尝试更新现有数据库中两个日期字段的默认值。这两个字段的SHOW CREATE TABLE输出如下:

  `dateIn` date DEFAULT '0000-00-00',
  `dateDue` date DEFAULT '0000-00-00',

但是,当我尝试通过命令行或通过phpMyAdmin更新其中一个字段时,我收到有关另一个字段的错误。

mysql> ALTER TABLE job MODIFY COLUMN dateIn date DEFAULT NULL;
ERROR 1067 (42000): 'dateDue'的无效默认值

请注意,错误中提到的字段并不是命令中的字段。我该如何解决此问题,而不破坏数据?

英文:

I'm trying to update the default values of two date fields in an existing database. The output of SHOW CREATE TABLE for these two fields is:

  `dateIn` date DEFAULT '0000-00-00',
  `dateDue` date DEFAULT '0000-00-00',

However, when I attempt to update one either through the command line or via phpMyAdmin, I receive an error regarding the other field.

mysql> ALTER TABLE job MODIFY COLUMN dateIn date DEFAULT NULL;
ERROR 1067 (42000): Invalid default value for 'dateDue'

Note that the field in the error is not the one in the command. How can I resolve this issue without destroying data?

答案1

得分: 1

@easleyfixed的建议使用MySQL Workbench证明是解决问题的良好方法,因为它创建了最佳的SQL,使我能够在同一命令中修改两列。

ALTER TABLE Examples

英文:

@easleyfixed's prompt to use MySQL Workbench turned out to solve the problem as it crafted the best SQL to enable me to modify both columns in the same command.

ALTER TABLE job
    MODIFY COLUMN dateIn  DATE DEFAULT NULL,
    MODIFY COLUMN dateDue DATE DEFAULT NULL;

ALTER TABLE Examples

huangapple
  • 本文由 发表于 2023年4月11日 05:45:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/75980969.html
匿名

发表评论

匿名网友

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

确定