问题
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