PostgreSQL alter type timestamp without time zone – >
发布时间:2020-12-13 16:44:05 所属栏目:百科 来源:网络整理
导读:问题很简单:如果我已经在一个列类型时间戳没有时区的数据,如果我设置类型为时间戳与时区,postgresql做这个数据是什么? 它保持当前值在本地时间,并将时区设置为本地时间的偏移量: create table a(t timestamp without time zone,t2 timestamp with time
问题很简单:如果我已经在一个列类型时间戳没有时区的数据,如果我设置类型为时间戳与时区,postgresql做这个数据是什么?
它保持当前值在本地时间,并将时区设置为本地时间的偏移量:
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 根据Alter Table手册:
根据Date/Time types手册
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |