小编Pad*_*han的帖子

将时间戳列更改为时间戳而不“转换”数据?

似乎将列从 更改为timestamp without time zonetimestamp with time zone根据语句时的当前会话时区转换现有数据alter

\n

请参阅此示例,每个语句后显示输出

\n
create table tztest (col1 timestamp without time zone);\n\nset timezone = 'UTC';\ninsert into tztest (col1) values ('2023-02-01 10:10:10');\nselect col1 as t1, extract(epoch FROM col1) from tztest;\n-- \xe2\x86\x92 2023-02-01 10:10:10    1675246210\n\nset timezone = 'America/New_York';\nalter table tztest alter column col1 type timestamp with time zone;\nselect col1 as t2, extract(epoch FROM col1) from tztest;\n-- \xe2\x86\x92 2023-02-01 10:10:10-05 1675264210\n\nset timezone = 'UTC';\nselect col1 as t3, extract(epoch FROM col1) …
Run Code Online (Sandbox Code Playgroud)

postgresql alter-table timezone

5
推荐指数
1
解决办法
2144
查看次数

标签 统计

alter-table ×1

postgresql ×1

timezone ×1