Postgresql 使用时区 UTC 创建表字段名时间戳



创建带有 UTC 时区字段的表的语法是什么?

我有字段:

(id INT PRIMARY KEY NOT NULL, 
 bravo timestamp without time zone DEFAULT now(),
 charlie timestamp with time zone UTC DEFAULT now()
)

由于某种原因,名为 charlie 的最后一个字段没有采用。 我希望这很容易,只需告诉它有一个时区,然后将UTC推入其中,并在输入过程中让数据库找出now()

我想你想要这个:

charlie timestamp without time zone NOT NULL
   DEFAULT (current_timestamp AT TIME ZONE 'UTC')

最新更新