ALTER表列到timestamp now()属性

时间:2014-04-13 12:51:39

标签: postgresql timestamp

我在互联网上找到的样本中创建了一个表格。列stored的定义是:

stored  | timestamp without time zone | default '2014-04-11 21:19:20.144487'::timestamp without time zone

如何将此更改为" normal" timestamp now()类型?那么它会在插入数据时标记当前日期时间吗?

提前谢谢大家!

2 个答案:

答案 0 :(得分:6)

如果您正在尝试change the default value。 。

alter table your-table-name
alter column stored set default current_timestamp

答案 1 :(得分:0)

要更改字段类型和默认值,语法将为......

alter table your-table-name
alter column your-field type timestamp,
alter column your-field set default current_timestamp;