如何在Postgresql间隔中写入40分钟
我阅读了Postgresql文档,但仍然不理解在向表中添加数据时如何编写间隔。我想在OmniDBs界面上花40分钟,但我不知道要用什么格式来编写它。有几种方法。这里有一些如何在Postgresql间隔中写入40分钟,postgresql,Postgresql,我阅读了Postgresql文档,但仍然不理解在向表中添加数据时如何编写间隔。我想在OmniDBs界面上花40分钟,但我不知道要用什么格式来编写它。有几种方法。这里有一些 select interval '40' minute ,-- using the minute keyword interval '40 minute' ,-- string description interval '0:40' ,-- hours and minutes 40 * interval
select
interval '40' minute ,-- using the minute keyword
interval '40 minute' ,-- string description
interval '0:40' ,-- hours and minutes
40 * interval '1m' ,-- using arithmetic on 1 minute
'0:40:00'::interval ,-- hours minutes and seconds, with a cast
'40 minutes'::interval ,-- string with a cast
interval '2400' ;-- that many seconds
注意:关键字必须是minute
,但在字符串描述中minutes
,m
和min
也可以使用
对于插入到postgres知道值应强制转换为强制类型的表中的操作,或者interval关键字可能是可选的
insert into times (t) values
(interval '40' minute ), -- using keyword interval also needed
('40 minute' ), -- string description
('0:40' ), -- 0 hours and 40 minutes
(40 * interval '1 m' ), -- for arithmetic interval is needed
('0:40:00' ), -- h:m:s
('40 minutes' ), -- string desc.
('2400' ); -- 2400 seconds
这里的文档
但这并没有描述关键字表单的用法。
间隔“40”分钟
尝试,在“40”附近出现语法错误:在“40”行1处或附近出现语法错误:…lues(1,1,1,“烹饪鸡肉”,1,间隔“40”分钟…尝试单引号由于某些原因,它没有正确粘贴。复制粘贴了您编写的内容只是为了清楚,我正在使用GUI IDE设置数据库,我选择了一种格式作为间隔,因为我认为将烹饪时间作为间隔是明智的,但文档关于这一点,谷歌完全是一派胡言。它没有给你一个具体的例子,而且谷歌搜索postgreSQL区间输入格式也不会产生太多的全局知识