【发布时间】:2018-01-13 18:39:09
【问题描述】:
我想在现有表中创建默认时间戳列。
我的第一个查询是
"ALTER TABLE {table_name} ADD COLUMN modifiedDate timestamp without time zone"
这有效并成功添加了列。
但是第二个查询
ALTER TABLE {table_name} ALTER modifiedDate SET DEFAULT '2001-01-01 00:00:00'::timestamp without time zone;
未能更新列上的所有行以包含该时间戳。
我在关注this SO 帖子。
我也试过一个查询
"ALTER TABLE {table_name} ADD COLUMN modifiedDate timestamp without time zone" SET DEFAULT '2001-01-01 00:00:00'::timestamp without time zone;
但这给出了错误syntax error at or near "00"
【问题讨论】:
标签: postgresql datetime time