本文介绍了更改时区约束PostgreSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这样的表中有一个属性:
I have an attribute in a table like this:
created_date timestamp without timezone
现在,我的要求是将生产数据库上的created_date字段更改为带有时区的时间戳,但我不知道如何更改此约束.
Now my requirement is to change the created_date field to the timestamp with timezone on the production database but I don't know how to alter this constraint.
推荐答案
要更改列类型,请使用 ALTER TABLE
命令:
To change a column type use ALTER TABLE
command:
ALTER TABLE yourtable ALTER COLUMN column_name TYPE timestamptz;
通过用逗号定界 ALTER COLUMN
语句,您可以在一个操作中更改一种以上的列类型:
You can change more than 1 column type in one operation by delimiting ALTER COLUMN
statements with a comma:
ALTER TABLE yourtable
ALTER COLUMN column_name TYPE timestamptz,
ALTER COLUMN column_name2 TYPE datatype;
有关更多信息,请参见文档.
For more information check documentation.
这篇关于更改时区约束PostgreSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!