Postgresql Postgres将unix时间的时间戳(以毫秒为单位)标记为bigint

Postgresql Postgres将unix时间的时间戳(以毫秒为单位)标记为bigint,postgresql,Postgresql,如何让以下代码片段在postgres中工作: ALTER TABLE mytable ADD COLUMN create_time_utc bigint not null DEFAULT (now() at time zone 'utc'); 我希望新列create_time_utc以毫秒为单位表示unix时间(即自unix纪元1970年1月1日起的毫秒数) 我知道我需要将postgres时间戳转换为bigint,但我不确定如何进行转换。提取(epoch alter table mytable

如何让以下代码片段在postgres中工作:

ALTER TABLE mytable
ADD COLUMN create_time_utc bigint not null
DEFAULT (now() at time zone 'utc');
我希望新列
create_time_utc
以毫秒为单位表示unix时间(即自unix纪元1970年1月1日起的毫秒数)

我知道我需要将postgres
时间戳转换为bigint,但我不确定如何进行转换。

提取(epoch

alter table mytable
add column create_time_utc bigint not null
default (extract(epoch from now()) * 1000);