英文:
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,使我能够在同一命令中修改两列。
英文:
@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;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论