[英]How to update TIMESTAMP WITH TIME ZONE columns with value of particular zone?
I have a TIMESTAMP WITH TIME ZONE column in my table. 我的表中有一个TIMESTAMP WITH TIME ZONE列。 I want to update all values with systimestamp at their respective timezones.
我想在各自的时区使用systimestamp更新所有值。
I have tried many ways, but i could not dynamically get timezone information from the value and update the same in a single query. 我尝试了很多方法,但是我无法从值中动态获取时区信息,也无法在单个查询中更新该信息。
I will provide the necessary structure here. 我将在此处提供必要的结构。
create table TIMEZONE_TEST
( COLUMN_ONE timestamp with time zone
);
insert into TIMEZONE_TEST values (systimestamp at time zone 'US/Pacific');
insert into TIMEZONE_TEST values (systimestamp at time zone 'Asia/Tokyo');
insert into TIMEZONE_TEST values (systimestamp at time zone 'Asia/Kuala_Lumpur');
insert into TIMEZONE_TEST values (systimestamp at time zone 'Asia/Singapore');
commit;
I need to update all values with systimestamp of particular timezones. 我需要使用特定时区的systimestamp更新所有值。
something like 就像是
update TIMEZONE_TEST
set COLUMN_ONE = systimestamp at time zone '<TIMEZONE_NAME of the value>';
Thanks for the kind help in advance. 感谢您的提前帮助。
I am not sure whether I got your question properly but I assume it should be this one: 我不确定是否能正确回答您的问题,但我想应该是这样的:
UPDATE TIMEZONE_TEST SET
COLUMN_ONE = FROM_TZ(CAST(SYSTIMESTAMP AS TIMESTAMP), EXTRACT(TIMEZONE_REGION FROM COLUMN_ONE));
The required answer was 所需答案是
UPDATE TIMEZONE_TEST
SET COLUMN_ONE = SYSTIMESTAMP at time zone EXTRACT(TIMEZONE_REGION FROM COLUMN_ONE);
I modified the answer given by @Wernfried. 我修改了@Wernfried给出的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.