我想在現有表中創建默認時間戳列。在PostgreSQL中創建默認時間戳
我的第一個查詢是
"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"