如何将没有时区的时间转换为没有时区的时间戳?

时间:2017-03-07 13:57:28

标签: sql postgresql

我需要在PSQL中的一个表中转换几列,我真的不想放弃表来解决这个问题(这是我的最后一招)。有没有办法做到这一点,因为当我写:

    ALTER TABLE table ALTER TABLE column type TIMESTAMP without time zone using column::TIMESTAMP without time zone; 

它不起作用,说:

    ERROR:cannot cast type time without time zone to timestamp without time zone.

P.S。如果可能,我想避免删除列,因为我已经使用了这些列的索引。

1 个答案:

答案 0 :(得分:10)

如果您希望日期部分为今天:

alter table the_table
alter column the_column type timestamp without time zone 
using current_date + the_column