Alter timezone constraint PostgreSQL

不想你离开。 提交于 2021-01-28 23:07:51

问题


I have an attribute in a table like this:

created_date timestamp without timezone

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.


回答1:


To change a column type use ALTER TABLE command:

ALTER TABLE yourtable ALTER COLUMN column_name TYPE timestamptz;

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.



来源:https://stackoverflow.com/questions/35676323/alter-timezone-constraint-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!