【发布时间】:2016-10-10 12:56:05
【问题描述】:
我正在使用 Postgresql 处理 Amazon Redshift 数据库。我有一个时间戳列,我需要将其转换为时间。我使用以下行来确定列属性:
select * from pg_table_def where tablename = 'tableA'
这一行详细说明了时间戳列的类型是“没有时区的时间戳”。
为了在 Postgresql 中测试转换方法,我尝试了以下行:
select '2016-10-01 12:12:12'::time
将时间戳转换为'12:12:12'
我想为表中的整个“时间戳”列重新创建它,但是当我运行以下行时遇到以下错误:
select timestamp::time from tableA
'SQL Error [500310] [0A000]: [Amazon](500310) Invalid operation: Specified types or functions (one per INFO message) not supported on Redshift tables.;
对于没有时区的时间戳列是否有限制将它们转换为时间?
我做错了什么,列的每条记录都没有转换为时间?
--编辑-- @halil 这是我从你那里使用的修改后的行。
select (extract(hour from timestamp) || ':' || extract(minute from timestamp) || ':' || extract(second from timestamp)) as my_time from tableA
--编辑-- @halil 这里是用于减去时间戳的行。我所做的只是从前一个时间戳中减去下一个时间戳:
select eventtimestamp - lead(eventtimestamp) over (order by eventtimestamp)
from ga_visit_events
【问题讨论】:
-
是 Redshift 还是 Postgres? Redshift 是基于这样一个旧版本的 Postgres,以至于这两者已经不再相同了。
-
它的红移,我在红移中使用 postgresql
-
没有“使用 postgres in redshift”。这是一个或另一个。不能两者兼有。
-
那时我正在使用redshift。
标签: amazon-redshift