sql >> Base de Datos >  >> RDS >> PostgreSQL

PostgreSQL alter type timestamp sin zona horaria -> con zona horaria

Mantiene el valor actual en la hora local y establece la zona horaria en el desplazamiento de su hora local:

create table a(t timestamp without time zone, t2 timestamp with time zone);
insert into a(t) values ('2012-03-01'::timestamp);
update a set t2 = t;
select * from a;
          t          |           t2           
---------------------+------------------------
 2012-03-01 00:00:00 | 2012-03-01 00:00:00-08

alter table a alter column t type timestamp with time zone;
select * from a;
           t            |           t2           
------------------------+------------------------
 2012-03-01 00:00:00-08 | 2012-03-01 00:00:00-08

Según el manual de Alter Table :

Según el manual para Tipos de fecha/hora