Hey I have just started working on PostgreSQL, and I am wondering how can we change a column's data type, I tried the following command:
alter table tableName alter column columnName type timestamp with time zone;
However I got the following message:
column "columnName" cannot be cast to type timestamp with time zone
The current column's data type is int, and i would like to change it to timestamp
Postgres doesn't know how to translate int to timestamp. There are several cases and usually they have different starting date.
If you look into documentation, you will find one line syntax with example how to convert unix time integer type:
ALTER [ COLUMN ] column [ SET DATA ] TYPE type [ USING expression ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With