我需要在PSQL中的一个表中转换几列,我真的不想放弃表来解决这个问题(这是我的最后一招).有没有办法做到这一点,因为当我写:
ALTER TABLE table ALTER TABLE column type TIMESTAMP without time zone using column::TIMESTAMP without time zone;
Run Code Online (Sandbox Code Playgroud)
它不起作用,说:
ERROR:cannot cast type time without time zone to timestamp without time zone.
Run Code Online (Sandbox Code Playgroud)
PS如果可能,我想避免删除列,因为我已经使用了这些列的索引.
Clo*_*eto 10
如果您希望日期部分为今天:
alter table the_table
alter column the_column type timestamp without time zone
using current_date + the_column
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3769 次 |
| 最近记录: |