PostgreSQL:从 5 分钟前的表中获取行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22390440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PostgreSQL: Obtain rows from table from 5 minutes ago
提问by Luke
I need to obtain from the following example table all the rows that match the exactly 5 minutes ago since the query is run.
我需要从下面的示例表中获取自查询运行以来恰好匹配 5 分钟前的所有行。
The query will be scheduled to run every 5 minutes to get all the rows that were created in that range of time.
该查询将安排为每 5 分钟运行一次,以获取在该时间范围内创建的所有行。
CREATE TABLE mytable
(
date timestamp without time zone NOT NULL,
id numeric(8)
)
I've tried with the interval option but because my table has the column defined as timestamp without time zone
I'm not getting the proper info that I need.
我已经尝试过间隔选项,但是因为我的表有列定义为timestamp without time zone
我没有得到我需要的正确信息。
回答by Cody Caughlan
Not sure why INTERVAL
is not working:
不知道为什么INTERVAL
不起作用:
SELECT * FROM mytable WHERE "date" >= NOW() - INTERVAL '5 minutes';